如何解决不能绘制网络模型,报错protobuf

来源:互联网 发布:spssk均值聚类算法 编辑:程序博客网 时间:2024/06/05 20:10

绘制网络模型,总显示这样的错误:

AttributeError: 'google.protobuf.pyext._message.RepeatedScalarConta' object has no attribute '_values'

具体内容见下:

caffe:>> ./python/draw_net.py ./examples/cifar10/cifar10_quick_train_test.prototxt ./visualization.pngDrawing net to ./visualization.pngTraceback (most recent call last):  File "./python/draw_net.py", line 45, in <module>    main()  File "./python/draw_net.py", line 41, in main    caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)  File "/home/andre/caffe/python/caffe/draw.py", line 222, in draw_net_to_file    fid.write(draw_net(caffe_net, rankdir, ext))  File "/home/andre/caffe/python/caffe/draw.py", line 204, in draw_net    return get_pydot_graph(caffe_net, rankdir).create(format=ext)  File "/home/andre/caffe/python/caffe/draw.py", line 151, in get_pydot_graph    node_label = get_layer_label(layer, rankdir)  File "/home/andre/caffe/python/caffe/draw.py", line 94, in get_layer_label    layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size._values) else 1,AttributeError: 'google.protobuf.pyext._message.RepeatedScalarConta' object has no attribute '_values'
这是由于你的protobuf的版本不对造成的,用pip install protobuf安装的版本号默认是最新的3.2.0。但是caffe不支持高于3.0.0版本的protobuf.

解决方法:卸载当前protobuf。(pip uninstall protobuf)

再指定安装低版本的,版主这里用的是2.5.0(pip install protobuf==2.5.0)

结束后再编译一遍pycaffe,就可以成功画出网络结构图了。

如果实在不能成功,也不要灰心,版主还提供在线网页绘制caffe网络结构图的方法,其实更简洁方便:

http://ethereon.github.io/netscope/#/editor

2 0