[BUG] visualizing graphs in evaluators.ipynb
lovettchris opened this issue · 2 comments
Describe the bug
arch.view() is cool, this must be a pytorch feature? Unfortunately, for this to work on windows one needs to manually install the graphviz installer from https://www.graphviz.org/download/#windows, I wonder if there's a better solution that integrates more nicely into jupyter?
What if we did this instead?
m = ss.random_sample()
import torch.onnx
x = torch.zeros(1,3,64,64) # don't know if there's an easier way to jin up a valid input for the model.
torch.onnx.export(m.arch, x, 'model.onnx', do_constant_folding=True)
# m.arch.view()
!pip install netron
import netron
netron.start('model.onnx', 8081)
Everyone has netron installed, and this works nicely on windows and the result is very pretty:
You can also add this to make the diagram show up inline:
import IPython
IPython.display.IFrame(f"http://localhost:8081", width=1000, height=1000)
I loved this idea! Didn't even think that it was possible to use netron
within Python.
What do you think @piero2c ?
Talking with Piero, graphviz
is necessary because we need an engine to parse the DOT files. There are some use cases in which we will not be able to export a model to ONNX, but we might want to render an image of the graph.
Still looking on other viable approaches, but every one of them requires an engine to be installed in order to parse the DOT into a readable format.