tensorwatch icon indicating copy to clipboard operation
tensorwatch copied to clipboard

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

Open lijipeng787 opened this issue 6 years ago • 5 comments

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 repr_svg(self) 11 def repr_svg(self): 12 """Allows Jupyter notebook to render the graph automatically.""" ---> 13 return self.dot.repr_svg() 14 def save(self, filename, format="png"): 15 # self.dot.format = format

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

lijipeng787 avatar Dec 05 '19 03:12 lijipeng787

I also encountered this problem, have you solved it?

xsola avatar Dec 12 '19 11:12 xsola

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

cloudpanl avatar Dec 13 '19 02:12 cloudpanl

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

pranavsekhar avatar Dec 27 '19 08:12 pranavsekhar

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

xsola avatar Dec 27 '19 09:12 xsola

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/[email protected]#egg=pydot

sytelus avatar Feb 07 '20 00:02 sytelus