东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 3640|回复: 0
打印 上一主题 下一主题

[课堂笔记] 运行caffe的python/draw_net.py报错:AttributeError: 'google.protobuf.pye...

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14429
QQ
跳转到指定楼层
楼主
发表于 2019-8-8 12:30:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
运行caffe的python/draw_net.py报错:AttributeError: 'google.protobuf.pyext._message.RepeatedScalarConta' object has no attribute '_values'


使用caffe的可视化工具  生成模型结构图



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


This requires pydot>=1.0.2, which is not included in requirements.txt since
    it requires graphviz and other prerequisites outside the scope of the
    Caffe.

sudo apt-get install graphviz

pydot is not supported under python 3 and pydot2 doesn't work properly.
pydotplus works nicely (pip install pydotplus)

遇到这个问题看到网上很多人说是protobuf的版本太高的缘故,但是东方耀亲自试了一下,将现有的protobuf3.9.1卸载,重新安装protobuf2.6.1 和 2.5.0
但是这个操作没有解决问题,反而出现了一些由于版本过低导致的报错,在此就不列举了。
因此在这里介绍另一种解决方案:

找到文件python/caffe/draw.py,将其94、96、98行变量后面的if ... else ...语句删除,变成(89-98行):


node_label = '"%s%s(%s)%skernel size: %d%sstride: %d%spad: %d"' %\
                     (layer.name,
                      separator,
                      layer.type,
                      separator,
                      layer.convolution_param.kernel_size[0],                #这里被修改了
                      separator,
                      layer.convolution_param.stride[0],                #这里被修改了
                      separator,
                      layer.convolution_param.pad[0]                #这里被修改了)



重新编译:


再运行应该就可以了。

另外Caffe的网页版可视化工具(需要翻墙):https://ethereon.github.io/netscope/#/editor


将*.prototxt中的内容复制到左边黑色文本框中,然后shift+enter即可在右边显示网络结构







让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-4-19 20:26 , Processed in 0.163157 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表