轉自:http://blog.csdn.net/u013078356/article/details/51154847
在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日志的記錄
GLOG_logtostderr=0 GLOG_log_dir=/home/liuyun/caffe/models/AAA/A12/Log/ \
/home/liuyun/caffe/build/tools/caffe train -solver examples/AAA/solver.prototxt -weights ./models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
其中目錄改成自己系統的目錄,這樣訓練結束之后,會在Log文件夾中生成每次訓練的Log日志。
2.解析訓練日志
將最上面說的3個腳本文件拷貝到Log 文件夾下,執行:
./parse_log.sh caffe.liuyun-860-088cn.root.log.INFO.20160830-090533.5367
這樣就會在當前文件夾下生成一個.train文件和一個.test文件
3.生成圖片
執行:
./plot_training_log.py.example 6 train_loss.png caffe.liuyun-860-088cn.root.log
注意:一定將caffe.liuyun-860-088cn.root.log.INFO.20160830-090533.5367改為caffe.liuyun-860-088cn.root.log,.log為后綴。
就可以生成訓練過程中的Train loss vs. Iters 曲線,其中6代表曲線類型, train_loss.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
最后,看一下效果: