def print_dot(node_list, link_list, out):
out.write('digraph{\n')
+ out.write(' graph [fontname = "helvetica"];\n')
+ out.write(' node [fontname = "helvetica"];\n')
+ out.write(' edge [fontname = "helvetica"];\n')
+
for n in node_list:
node = node_list[n]
if isinstance(n, torch.autograd.Variable):
out.write(
' ' + \
- str(node.id) + ' [shape=note,label="' + \
+ str(node.id) + ' [shape=note,style=filled, fillcolor="#e0e0ff",label="' + \
node.label + ' ' + re.search('torch\.Size\((.*)\)', str(n.data.size())).group(1) + \
'"]\n'
)
else:
out.write(
' ' + \
- str(node.id) + ' [shape=record,label="{ ' + \
+ str(node.id) + ' [shape=record,style=filled, fillcolor="#f0f0f0",label="{ ' + \
slot_string(node.max_out, for_input = True) + \
node.label + \
slot_string(node.max_in, for_input = False) + \
print('Generated mlp.dot')
try:
- subprocess.check_call(["dot", "mlp.dot", "-Lg", "-T", "pdf", "-o", "mlp.pdf" ])
+ subprocess.check_call(['dot', 'mlp.dot', '-Lg', '-T', 'pdf', '-o', 'mlp.pdf' ])
except subprocess.CalledProcessError:
print('Calling the dot command failed. Is Graphviz installed?')
sys.exit(1)