microsoft / tensorwatch

Debugging, monitoring and visualization for Python Machine Learning and Data Science
MIT License
3.42k stars 362 forks source link

AttributeError: 'Dot' object has no attribute '_repr_svg_' #52

Open lijipeng787 opened 4 years ago

lijipeng787 commented 4 years ago

my usage like this: model = Model() tw.draw_model(model, [1, 2, 256, 256])

and get error message:

AttributeError Traceback (most recent call last) ~/miniconda2/envs/pytorch_env/lib/python3.6/site-packages/IPython/core/formatters.py in call(self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method is not None: --> 345 return method() 346 return None 347 else:

~/miniconda2/envs/pytorch_env/lib/python3.6/site-packages/tensorwatch/model_graph/hiddenlayer/pytorch_draw_model.py in _reprsvg(self) 11 def _reprsvg(self): 12 """Allows Jupyter notebook to render the graph automatically.""" ---> 13 return self.dot._reprsvg() 14 def save(self, filename, format="png"): 15 # self.dot.format = format

AttributeError: 'Dot' object has no attribute '_reprsvg'

xsola commented 4 years ago

I also encountered this problem, have you solved it?

cloudpanl commented 4 years ago

This issue has been fixed, modifying pytorch_draw_model.py like this can be solved. #51

pranavsekhar commented 4 years ago

Hm, the fix in #51 isn't working for me. Did it work for either of you?

xsola commented 4 years ago

Hm, the fix in #51 isn't working for me. Did it work for either of you?

Yes, it works for me. Maybe you should try to restart your jupyter notebook or just reimport tensorwatch after modifying pytorch_draw_model.py

sytelus commented 4 years ago

I debugged this issue and it appears that pydot needs to be updated to resolve this error (see this comment). Unfortunately, pydot seems like an unmaintained project so I forked pydot and applied open PRs against it which resolves this issue. If you are facing this issue, I would suggest to reinstall pydot from my fork: https://github.com/sytelus/pydot.

TensorWatch is updated to use pydot from above fork however it will only affect new installations because pip doesn't detect vertion changes from package installed from git URLs.

So in nutshell, do this:

pip uninstall pydot
pip install git+https://github.com/sytelus/pydot@v1.5.0#egg=pydot