end
----------------------------------------------------------------------
+
+function DAG:dot(filename)
+ local file = (filename and io.open(filename, 'w')) or io.stdout
+
+ file:write('digraph {\n')
+
+ file:write('\n')
+
+ for nnma, node in pairs(self.node) do
+ file:write(
+ ' '
+ .. node.index
+ .. ' [shape=box,label=\"' .. torch.type(nnma) .. '\"]'
+ .. '\n'
+ )
+
+ for _, nnmb in pairs(node.succ) do
+ file:write(
+ ' '
+ .. node.index
+ .. ' -> '
+ .. self.node[nnmb].index
+ .. '\n'
+ )
+ end
+
+ file:write('\n')
+ end
+
+ file:write('}\n')
+
+end
output:uniform()
print('Error = ' .. checkGrad(model, nn.MSECriterion(), input, output))
+
+model:dot('/tmp/graph.dot')