Skip to content

Instantly share code, notes, and snippets.

@gcr
Created January 6, 2016 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcr/a20cd62636e266e28708 to your computer and use it in GitHub Desktop.
Save gcr/a20cd62636e266e28708 to your computer and use it in GitHub Desktop.
json = require 'cjson'
function buildNcduLayer(name, module)
local result = nil
if torch.isTensor(module) then
if module:numel() ~= 0 then
local strt = {name..': [' .. torch.typename(module) .. ' of size '}
for i=1,module:nDimension() do
table.insert(strt, module:size(i))
if i ~= module:nDimension() then
table.insert(strt, 'x')
end
end
table.insert(strt, ']')
result = {name = table.concat(strt),
dsize = module:numel() * module:storage():elementSize()
}
else
result = {name = name..": [empty "..torch.typename(module).."]"}
end
elseif type(module)=="table" and module.modules then
result = { {name = name..": "..string.gsub(tostring(module), "\n", " ")} }
for i,m in ipairs(module.modules) do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment