运行mnist示例:
1、得到数据
cd ~/caffe
sudo sh data/mnist/get_mnist.sh
2、制作符合caffe要求的数据
sudo sh examples/mnist/create_mnist.sh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
此段主要是当时运行程序有些问题及处理方法
当时不方便打汉字,采用了中式英文注解~~
bad luck,terminal appear these:
Creating lmdb...
examples/mnist/create_mnist.sh: 17: examples/mnist/create_mnist.sh: build/examples/mnist/convert_mnist_data.bin: not found
solve method see following website:
https://blog.csdn.net/wangxing233/article/details/51734080
but it not solve this
following website :
https://blog.csdn.net/huaxie3355/article/details/71055704
can solve the problem
cd caffe
make all -j4
so,do this ,problem is solved
following website good
https://blog.csdn.net/dcxhun3/article/details/51859740#commentBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3、修改lenet_solver.prototxt和train_lenet.prototxt 网络配置(使用GPU就不用改了)
cd ~/caffe
subl ./examples/mnist/lenet_solver.prototxt
设置 solver_mode: CPU ,使用GPU就不用改了
train_lenet.prototxt 可以不用修改
4、训练网络
cd ~/caffe
sudo time sh examples/mnist/train_lenet.sh
5、画出训练网络的结构图
cd ~/caffe/python
python draw_net.py ../examples/mnist/lenet_train_test.prototxt lenet.png
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
画网络过程可能会出现如下报错:
Traceback (most recent call last):
File "draw_net.py", line 94, in <module>
main()
File "draw_net.py", line 90, in main
phase)
File "/home/pikachu/caffe/intel/caffe/python/caffe/draw.py", line 280, in draw_net_to_file
fid.write(draw_net(caffe_net, rankdir, ext, phase))
File "/home/pikachu/caffe/intel/caffe/python/caffe/draw.py", line 259, in draw_net
return get_pydot_graph(caffe_net, rankdir, phase=phase).create(format=ext)
File "/home/pikachu/.local/lib/python2.7/site-packages/pydot.py", line 1883, in create
prog=prog))
Exception: "dot" not found in path.
这是因为在编译pycaffe 之前安装的一些依赖库不全造成的,缺啥就安装啥吧,这里缺少dot,因此:
sudo pip install pydot
执行这条命令后,再此执行:
cd ~/caffe/python
python draw_net.py ../examples/mnist/lenet_train_test.prototxt lenet_train_test.png
python draw_net.py ../examples/mnist/lenet.prototxt lenet.png
有时安装pydot后,还可能需要安装graphviz:
sudo apt install graphviz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%