1.采用caffe自带的方法绘制训练过程的loss和accuracy曲线
1)首先打印训练过程中的日志log文件:
在训练代码中添加如下两种(任一)代码:
#!/bin/bash
GLOG_logtostderr=0 GLOG_log_dir=/home/hsm/project/facialexpress/convnet1/Log/ \
/home/hsm/project/facialexpress/caffe/build/tools/caffe train --solver=/home/hsm/project/facialexpress/convnet1/convnet1_solver.prototxt
将生成的文件名类似caffe.hdu127-T630.hsm.log.INFO.20171123-155200.10192 日志文件改名为net1_train_log.log文件。
#!/bin/bash
TOOLS=/home/hsm/project/facialexpress/caffe/build/tools
$TOOLS/caffe train --solver=/home/hsm/project/facialexpress/convnet1/convnet1_solver.prototxt 2>&1 | tee /home/hsm/project/facialexpress/convnet1/Log/net1_train_log.log
2)然后将caffe/tools/extra文件夹下的parse_log.sh ,extract_seconds.py和 plot_training_log.py.example 文件拷贝至日志所在文件夹下/home/hsm/project/facialexpress/convnet1/Log/
3)执行命令
./plot_training_log.py 0 test2.png net1_train_log.log //0表示要绘制的图像类型
执行上述命令后生成net1_train_log.log.test , net1_train_log.log.train文件用于分别绘制test和train的相关图像,并报如下错误:
2.错误一:执行上述命令后,就卡住没有下文了
详细查看并print测试plot_training_log.py代码后,终于报错了,如下:
3.关于_tkinter.TclError: no display name and no $DISPLAY environment variable错误解决办法:
在仔细测试plot_training_log.py代码过程中,发现跟下面这个函数有关,
搜索了plot函数的具体使用后,发现貌似和Matplotlib有关,尝试更改matplotlib的后端模式为”Agg:
(在plot_training_log.py文件中添加)代码如下:
# do this before importing pylab or pyplot
Import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot asplt
再次执行1.3)中的绘图命令,成功地画出了图;
就没有再去修改下面链接中Agg的配置等操作。
参考链接:https://www.lookfor404.com/%E8%BF%90%E8%A1%8Cggplot%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98no-display-name-and-no-display-environment-variable/