Caffe MNIST训练lenet网络

1.下载mnist数据库

// cd 到caffe根目录
$ ./data/mnist/get_mnist.sh
// 转换成lmdb数据格式
$ ./examples/mnist/create_mnist.sh
// 训练mnist模型
$ ./examples/mnist/train_lenet.sh
// 默认是GPU模式进行训练的

2.本地可视化lenet网络图

$ sudo -H pip install pydot      //需要安装pydot,否则画图会提示报错
$ sudo apt-get install graphviz  //否则会提示Exception: "dot" not found in path.
$ python python/draw_net.py xxx.prototxt xxx.png --rankdir=TB

3.在线可视化工具

http://ethereon.github.io/netscope/#/editor 
  1. draw_net.py画图工具使用问题:
//问题现象如下
......
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' 
//python/caffe/draw.py 文件修改如下:
   (layer.name,
    separator,
    layer.type,
    separator,	
+   layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size) else 1,                       
-   layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size._values) else 1,
    separator,
+   layer.convolution_param.stride[0] if len(layer.convolution_param.stride) else 1,                       
-   layer.convolution_param.stride[0] if len(layer.convolution_param.stride._values) else 1,
    separator,
-   layer.convolution_param.pad[0] if len(layer.convolution_param.pad._values) else 0)
+   layer.convolution_param.pad[0] if len(layer.convolution_param.pad) else 0)

你可能感兴趣的:(caffe)