projects
/
dagnn.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
501034f
)
Added DAG:setLabel to add a label to a module in the graph.
author
Francois Fleuret
<francois@fleuret.org>
Mon, 16 Jan 2017 06:39:34 +0000
(07:39 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Mon, 16 Jan 2017 06:39:34 +0000
(07:39 +0100)
dagnn.lua
patch
|
blob
|
history
diff --git
a/dagnn.lua
b/dagnn.lua
index
ca26926
..
f9d6ff9
100755
(executable)
--- a/
dagnn.lua
+++ b/
dagnn.lua
@@
-148,6
+148,10
@@
function DAG:connect(...)
end
end
end
end
+function DAG:setLabel(nnm, label)
+ self.node[nnm].label = label
+end
+
function DAG:setInput(i)
self.sorted = nil
self.inputModules = i
function DAG:setInput(i)
self.sorted = nil
self.inputModules = i
@@
-176,7
+180,11
@@
function DAG:print()
self:putInOrder()
for i, d in ipairs(self.sorted) do
self:putInOrder()
for i, d in ipairs(self.sorted) do
- print('#' .. i .. ' -> ' .. torch.type(d))
+ local decoration = ''
+ if self.node[d].label then
+ decoration = ' [' .. self.node[d].label .. ']'
+ end
+ print('#' .. i .. ' -> ' .. torch.type(d) .. decoration)
end
end
end
end
@@
-211,7
+219,7
@@
function DAG:saveDot(filename)
file:write(
' '
.. node.index
file:write(
' '
.. node.index
- .. ' [shape=box,label=\"' ..
torch.type(nnmb
) .. '\"]'
+ .. ' [shape=box,label=\"' ..
(self.node[nnmb].label or torch.type(nnmb)
) .. '\"]'
.. '\n'
)
.. '\n'
)