转自:http://blog.csdn.net/u013078356/article/details/51154847
作者:csuwujiyang
在caffe的训练过程中,大家难免想图形化自己的训练数据,以便更好的展示结果。如果自己写代码记录训练过程的数据,那就太麻烦了,caffe中其实已经自带了这样的小工具 caffe-master/tools/extra/parse_log.sh caffe-master/tools/extra/extract_seconds.py和 caffe-master/tools/extra/plot_training_log.py.example ,使用方法如下:
1.记录训练日志
在训练过程中的命令中加入一行参数 ,实现Log日志的记录
- TOOLS=./build/tools
- GLOG_logtostderr=0 GLOG_log_dir=deepid/deepid2/Log/ \
- $TOOLS/caffe train \
- --solver=deepid/deepid2/deepid_solver.prototxt
TOOLS=./build/tools
GLOG_logtostderr=0 GLOG_log_dir=deepid/deepid2/Log/ \
$TOOLS/caffe train \
--solver=deepid/deepid2/deepid_solver.prototxt
其中目录改成自己系统的目录,这样训练结束之后,会在Log文件夹中生成每次训练的Log日志
2.解析训练日志
将最上面说的3个脚本文件拷贝到Log 文件夹下,执行:
- ./parse_log.sh caffe.wujiyang-ubuntu.wujiyang.log
./parse_log.sh caffe.wujiyang-ubuntu.wujiyang.log
后面的参数为log文件名,这样就会在当前文件夹下生成一个.train文件和一个.test文件
3.生成图片
执行
- ./plot_training_log.py.example 0 save.png caffe.wujiyang-ubuntu.wujiyang.log
./plot_training_log.py.example 0 save.png caffe.wujiyang-ubuntu.wujiyang.log
就可以生成训练过程中的Test accuracy vs. Iters 曲线,其中0代表曲线类型, save.png 代表保存的图片名称
caffe中支持很多种曲线绘制,通过指定不同的类型参数即可,具体参数如下
- 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
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
最后,看一下效果