tensorboardX使用中 AttributeError: 'function' object has no attribute 'graph'

最近在使用tensorboardX可视化网络结构,因为tensorboardX并非pytorch原生的可视化工具,所以版本之间并不兼容

在使用的过程中会遇到,AttributeError: 'function' object has no attribute 'graph',大概是版本之间不兼容

完整错误如下

Traceback (most recent call last):
  File "source_hourglassnet.py", line 181, in <module>
    writer.add_graph(model, (input_data, ))
  File "/home/yongjie/anaconda2/envs/danfeng/lib/python3.6/site-packages/tensorboardX/writer.py", line 738, in add_graph
    self._get_file_writer().add_graph(graph(model, input_to_model, verbose, **kwargs))
  File "/home/yongjie/anaconda2/envs/danfeng/lib/python3.6/site-packages/tensorboardX/pytorch_graph.py", line 241, in graph
    graph = trace.graph
AttributeError: 'function' object has no attribute 'graph'
View Code

搜到了一个解决方案说的是tensorboardX1.8对于低版本的pytorch支持不是很好

conda list发现 tensorboardX确实是1.8版本的,pip uninstall tensorboardX之后再

重新安装pip install tensorboardX=1.4

安装完之后就可以正常使用了

没毛病

 

但是这里有另外一个问题就是,我用pip search tensorboardX

的时候并没有发现1.4版本的,但是我用pip install tensorboardX=1.4的时候是可以使用的,不知道为啥

posted on 2019-08-06 22:38  YongjieShi  阅读(2766)  评论(0编辑  收藏  举报

导航