caffe 训练增加日志,画accuracy曲线

时间:2022-11-05 08:10:24

首先在当前创建文件夹log : mkdir log
在bash文件 train.sh 添加:

LOG=log/train-`date +%Y-%m-%d-%H-%M-%S`.log
TOOLS=/opt/caffe-py3/build/tools
$TOOLS/caffe train -solver='LCNN_solver.prototxt' --gpu=0 2>&1 | tee $LOG

训练玩在log文件夹下会有 .log文件

把caffe-master/tools/extra/路径下的3个文件
- parse_log.sh
- extract_seconds.py
- plot_training_log.py.example
执行bash parse_log.sh ***.log,会生成.train 和.test文件
再执行 ./plot_training_log.py.example 6 trainloss.png train-2017-02-17-10-57-03.log就会得到图,其中参数如下:

    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  

我执行的是6 trainloss vs. iters

end

.sh  grep 'loss =' $1 | awk '{print $13}' > aux1.txt
cat aux1.txt