我们打开./caffe/examples/myself/文件夹下面的训练脚本文件:train_quick.sh,然后,在这个脚本文件的后面添加下面的语句:
2>&1 | tee examples/myself/cifar_train_log.log //这个是你的log日志文件的保存目录
修改之后的完整的训练脚本文件如下所示:
#!/usr/bin/env sh
set -e
TOOLS=./build/tools
$TOOLS/caffe train \
--solver=examples/myself/cifar10_quick_solver.prototxt 2>&1 | tee examples/myself/cifar_train_log.log
日志文件的具体内容如下所示:
I1103 21:24:56.893302 5598 caffe.cpp:210] Use CPU.
I1103 21:24:56.893492 5598 solver.cpp:48] Initializing solver from parameters:
test_iter: 10
test_interval: 50
base_lr: 0.001
display: 20
max_iter: 500
lr_policy: "fixed"
momentum: 0.9
weight_decay: 0.004
snapshot: 400
snapshot_prefix: "examples/myself/cifar10_quick"
solver_mode: CPU
net: "examples/myself/cifar10_quick_train_test.prototxt"
train_state {
level: 0
stage: ""
}
中间省略.....................
I1103 21:25:25.338564 5598 solver.cpp:464] Snapshotting to HDF5 file examples/myself/cifar10_quick_iter_500.caffemodel.h5
I1103 21:25:25.339599 5598 sgd_solver.cpp:283] Snapshotting solver state to HDF5 file examples/myself/cifar10_quick_iter_500.solverstate.h5
I1103 21:25:25.363062 5598 solver.cpp:317] Iteration 500, loss = 0.0766577
I1103 21:25:25.363101 5598 solver.cpp:337] Iteration 500, Testing net (#0)
I1103 21:25:25.585652 5598 solver.cpp:404] Test net output #0: accuracy = 0.91
I1103 21:25:25.585676 5598 solver.cpp:404] Test net output #1: loss = 0.292251 (* 1 = 0.292251 loss)
I1103 21:25:25.585681 5598 solver.cpp:322] Optimization Done.
I1103 21:25:25.585683 5598 caffe.cpp:254] Optimization Done.
第一步:首先,将./caffe/tools/extra/文件夹下面的:
1---extract_seconds.py
2---parse_log.sh
3---plot_training_log.py.example
将这三个文件复制到[日志文件]所在的目录下面,如下图所示:
第二步:首先,使用命令:cd ./caffe/examples/myself/切换到日志文件所在的目录下,然后运行:
./parse_log.sh cifar_train_log.log
如下图所示:
对日志文件进行解析,日志文件解析成功之后,会在本目录下生成两个文件:
1---cifar_train_log.log.test
2---cifar_train_log.log.train
如下图所示:
第三步:执行命令,生成Accuracy和Loss曲线:
1---下面的命令是:以迭代次数为X轴,以准确率为Y轴的Accuracy曲线:
命令如下图所示:
Accuracy曲线如下图所示:
以运行时间为X轴,以准确率为Y轴,的命令和曲线图如下所示:
第四步:Loss曲线的生成
以迭代次数为X轴,以损失率为Y轴,命令和Loss曲线如下所示:
各种曲线的具体参数,如下所示:
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