caffe执行draw.py的错误汇总
发表于2017/5/11 17:18:43 89人阅读
caffe执行draw.py的错误汇总
安装完caffe后,使用caffe时,有时候需要调用draw.py来画整个神经网络拓扑图,不过github上最新版本运行draw.py会报错,具体如下
错误1:
执行命令
$cd caffe/python/
$python draw_net.py ../examples/mnist/lenet_train_test.prototxt lenet.png
会报如下错误:
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
或者pip install pydot
再次运行:python draw_net.py ../examples/mnist/lenet_train_test.prototxt lenet.png
又出现错误了:pydot.InvocationException: GraphViz's executables not found,坑爹。此时需要安装graphviz,命令为sudo apt-get install graphviz
最后再运行一次,终于成功了。在python文件夹下得到lenet.png文件了。如下图:
错误:
Traceback (most recent call last):
File "draw_net.py", line 58, in <module>
main()
File "draw_net.py", line 54, in main
phase)
File "/home/ph/caffe/python/caffe/draw.py", line 244, in draw_net_to_file
fid.write(draw_net(caffe_net, rankdir, ext, phase))
File "/home/ph/caffe/python/caffe/draw.py", line 223, in draw_net
return get_pydot_graph(caffe_net, rankdir, phase=phase).create(format=ext)
File "/home/ph/anaconda2/lib/python2.7/site-packages/pydot.py", line 1876, in create
prog=prog))
Exception: "dot" not found in path.
解决方法:sudo apt-get install graphviz
错误ImportError: No module named google.prototxt
解决方法:
安装python-protobuf
- sudo apt-get install Python-protobuf
sudo apt-get install Python-protobuf
错误3:
修复好错误1的情况下,执行
$python draw_net.py ../examples/mnist/lenet_train_test.prototxt lenet.png
会报如下错误:
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/releases 找到cold-brew版本,然后下载Source code(zip),解压后将caffe/python/draw_net.py复
制并替换掉原先的draw_net文件即可
这是我下载好的,可直接下载 链接:链接:http://pan.baidu.com/s/1mhCvFmC 密码:5imd
//https://github.com/BVLC/caffe/issues/5324
//文章链接上说是由于caffe中draw.py本身错误引起,用老版本的caffe中draw.py代替如果从直接github上下载的代码的话,最好
用gitpull直接更新代码,git上最新的代码没有问题。