Open HiYellowC opened 6 years ago
Use:
dot.format = format
dot.render(filename)
where
dot
is graph representation return using make_dot
format
is format from graphviz
(see https://graphviz.readthedocs.io/en/stable/manual.html#formats)filename
specifies path, where to save graphI tried to do that and the image I get is nonetype:
disp = model(imgL,imgR)
dot = make_dot(disp)
print(dot)
dot.render("test.png")
@soulslicer Try like this
x = torch.zeros(1, 3, 224, 224, dtype=torch.float, requires_grad=False) out = model(x) dot=make_dot(out) print(dot) dot.format = 'png' dot.render("filename")
where
You will get a "filename.png" image file. You can specify different format like 'svg' if you need.
@kamalravi it gives
----> 7 dot.format("png")
8 dot.render("danet_model")
TypeError: 'str' object is not callable
I think a full example for saving might be helpful, especially for those not immediately familiar with graphviz.
dot = torchviz.make_dot(y.mean(), params=dict(model.named_parameters()))
dot.format = 'png'
dot.render('torchviz-sample')
And the image is saved under the current working directory as torchviz-sample.png
.
how can I save the output as png or jpg?