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

在尝试绘制网络模型时遇到AttributeError,提示protobuf对象无属性 '_values'。通过卸载现有protobuf并安装版本2.5.0,然后重新编译pycaffe,可以解决问题。若仍不成功,推荐使用在线工具如Netscope进行网络结构图的简洁绘制。

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

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

具体内容见下:

caffe:>> ./python/draw_net.py ./examples/cifar10/cifar10_quick_train_test.prototxt ./visualization.png
Drawing net to ./visualization.png
Traceback (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

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值