参考文档:
caffe网络模型各层详解(中文版),一份详细说明caffe prototxt的文档
caffe的总体流程
准备数据 ==> 定义Net ==> 配置Solver ==> Run ==> 分析结果
画网络结构的图形表示
进入网络模型的prototxt文件所在位置,运行下面命令,会在当前位置输出xxx.png
python ~/caffe/python/draw_net.py xxx.prototxt xxx.png --rankdir=BT
# BT=Bottom to Top,该参数还可以为TB,LR,RL等
caffe命令
caffe后可跟4个命令:
- train:训练
caffe train -solver lenet_solver.prototxt
#保存训练log文件
caffe train -solver lenet_solver.prototxt 2>1 | tee train.log #屏幕没有输出
caffe train -solver lenet_solver.prototxt 2>&1 | tee train.log #屏幕也有输出
#2>1是重定向错误输出到标准输出
- test
- device_query
- time:评估模型运行时间
caffe time -model lenet.prototxt -iterations 100 # cpu上跑
caffe time -model lenet.prototxt -iterations 100 -gpu 0 # 0号GPU上跑
绘制loss曲线
先保存训练的log文件,然后
- 法1:直接用caffe/tools/extra中的plot_training_log.py.example
输入:python tools/extra/plot_training_log.py.example会输出该函数的用法信息
Usage:
./plot_training_log.py chart_type[0-7] /where/to/save.png /path/to/first.log ...
Notes:
1. Supporting multiple logs.
2. Log file name must end with the lower-cased ".log".
Supported chart types:
0: Test accuracy vs. Iters
1: Test accuracy vs. Seconds
2: Test loss vs. Iters
3: Test loss vs. Seconds
4: Train learning rate vs. Iters
5: Train learning rate vs. Seconds
6: Train loss vs. Iters
7: Train loss vs. Seconds
例如:
python tools/extra/plot_training_log.py.example 6 loss.png path/to/train.log
#会在当前目录生成train.log.train, tarin.log.test两个解析出的文件和loss.png图片
- 法2:用caffe/tools/extra中的parse_log.py.解析出log.train和log.test文件,然后自己用matplotlib画
用法:
python tools/extra/parse_log.py logfile_path output_dir