0

I am trying to use torchviz but it's not giving any output. No error or warning either..

import numpy as np
import torch
from torchviz import make_dot
yhat= a+b*x_train_tensor
make_dot(yhat).render("attached", format="png")

I also tried using make_dot(yhat) but that doesn't work either. In the above only a small file with the name "attached" is being created but is not an image. Obviously x_train_tensor and yhat are all tensors and compute just fine. It's the visualization that I'm having trouble with.

I have already seen these posts.

How do I visualize a net in Pytorch?

https://github.com/szagoruyko/pytorchviz/issues/5

But couldn't solve the problem. I'm using python 3.7.4 64 bit in vscode

  • It is important however, that one of your variables requires gradient. If not there is no dependency graph which is what I think torchviz draws. For example: `x_train_tensor = torch.rand(10, requires_grad=True)`. I am unable to reproduce the error. I mean, torchviz creates an image of the graph – BCJuan Apr 25 '20 at 16:11
  • @BCJuan it has gradient..as I said earlier the code works fine. The gradients work properly. It's just the visualization that I'm struggling with. – HITAISHI BARAI Apr 25 '20 at 16:37

1 Answers1

0

I can't say why your code is not producing a .png without seeing the rest of it, but you could try displaying the the small file "attached" you mention. It is a .dot file. Rename it to something.dot. See this post for example https://stackoverflow.com/questions/1494492/graphviz-how-to-go-from-dot-to-a-graphf for how to display a .dot file.