Created
January 6, 2016 19:06
-
-
Save gcr/a20cd62636e266e28708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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