python画框架_caffe drawnet.py 用Python画网络框架

在caffe中可以使用draw_net.py轻松地绘制卷积神经网络(CNN,Convolutional Neural Networks)的架构图。这个工具对于我们理解、学习甚至查错都有很大的帮助。

1、draw_net.py的使用方法如下:

usage: draw_net.py [-h] [--rankdir RANKDIR]

input_net_proto_file output_image_file

Draw a graph of the net architecture.

positional arguments:

input_net_proto_file Input network prototxt file

output_image_file Output image file

optional arguments:

-h, --help show this help message and exit

--rankdir RANKDIR One of TB (top-bottom, i.e., vertical), RL (right-

left, i.e., horizontal), or another valid dot option;

see

http://www.graphviz.org/doc/info/attrs.html#k:rankdir

(default: LR)

其中,–rankdir选项确定了输出图片的摆放位置,如TB (Top-Bottom) 就是网络从上到下访问,同理RL (Right-Left)就是从右向左,LR (Left-Right) 就是从左向右摆放。默认使用的是LR方式。

下面的代码输出了卷积神经网络经典的LeNet的网络结构

/home/cheche/caffe-master/python# python draw_net.py --rankdir TB ../examples/mnist/lenet.prototxt ../examples/mnist/lenet_structure.jpg

2、出错解决方案

(1)、提示“ImportError: no  module named pydot”

解决方案:返回系统根目录,用命令“pip install pydot”安装“pydot”

(2)、安装完pydot后,再次进入"../caffe-master/python#"目录,运行1中的命令进行绘图,出现新问题““AttributeError: ‘google.protobuf.pyext._message.RepeatedScalarConta’ object has no attribute ‘_values””

实际上是由于protobuf(例如centos7(protobuf=3.2)) 版本过高导致。

解决办法:

返回系统根目录,运行以下代码重新安装protobuf

pip uninstall protobuf

pip install protobuf==2.6.0

(3)、如果上述步骤不能解决问题,可以使用在线绘图

感谢以下作者:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值