caffe执行draw.py的错误汇总
安装完caffe后,使用caffe时,有时候需要调用draw.py来画整个神经网络拓扑图,不过github上最新版本运行draw.py会报错,具体如下
错误1:
执行命令
$cd caffe/python/
$python draw_net.py--rankdirTB ../examples/mnist/lenet.prototxt../examples/mnist/lenet_structure.jpg
会报如下错误:
Traceback(most recent call last):
File"draw_net.py", line 9, in <module>
importcaffe.draw
File"/root/caffe/python/caffe/draw.py", line 22, in <module>
import pydot
ImportError:No module named pydot
解决方法,安装pydot
sudo apt-get install python-pydot
或者pipinstall pydot
错误2:
修复好错误1的情况下,执行
$python draw_net.py--rankdirTB ../examples/mnist/lenet.prototxt../examples/mnist/lenet_structure.jpg
会报如下错误:
Traceback(most recent call last):
File"draw_net.py", line 58, in <module>
main()
File"draw_net.py", line 54, in main
phase)
File"/root/caffe/python/caffe/draw.py", line 244, indraw_net_to_file
fid.write(draw_net(caffe_net,rankdir, ext, phase))
File"/root/caffe/python/caffe/draw.py", line 223, in draw_net
returnget_pydot_graph(caffe_net, rankdir, phase=phase).create(format=ext)
File"/root/caffe/python/caffe/draw.py", line 167, inget_pydot_graph
node_label= get_layer_label(layer, rankdir)
File"/root/caffe/python/caffe/draw.py", line 107, inget_layer_label
layer.pooling_param.kernel_size[0]if len(layer.pooling_param.kernel_size._values) else 1,
AttributeError:'int' object has no attribute '_values'
解决方案
github上查找解决方案
https://github.com/BVLC/caffe/issues/5324
文章链接上说是由于caffe中draw.py本身错误引起,用老版本的caffe中draw.py代替如果从直接github上下载的代码的话,最好用gitpull直接更新代码,git上最新的代码没有问题。