采用程序为:caffe/tools/extra/plot_training_log.py.example
用法参考博客:http://blog.csdn.net/u013078356/article/details/51154847
直接使用,发现报错,查看parse_log.py 生成的文件 *.train *.test,发现改动以下地方,即可正常工作:
1 标题的顺序,原来是 loss:2,learning:3,现将顺序对调一下
def create_field_index():
train_key = 'Train'
test_key = 'Test'
field_index = {train_key:{'Iters':0, 'Seconds':1, train_key + ' learning rate':2,
train_key + ' loss':3},
test_key:{'Iters':0, 'Seconds':1, test_key + ' learning rate':2,
test_key + ' accuracy':3,
test_key + ' loss':4}}
fields = set()
for data_file_type in field_index.keys():
fields = fields.union(set(field_index[data_file_type].keys()))
fields = list(fields)
fields.sort()
return field_index, fields
def load_data(data_file, field_idx0, field_idx1):
data = [[], []]
with open(data_file, 'r') as f:
for line in f:
line = line.strip()
print('line:',line)
if line[0] != 'N':
fields = line.split(',')
data[0].append(float(fields[field_idx0].strip()))
data[1].append(float(fields[field_idx1].strip()))
return data
为了使用方便,写了以下sh文件,方便使用:
LOGDIR=/Users/zhaomingming/Downloads/caffe-ssd/examples/cifar10/Log
#分析出accuracy,Iters,lr,loss等参数,写入LOgDIR文件夹下的*.train,*.test文件中
./tools/extra/parse_log.py $LOGDIR/caffe.zhaomac.lan.root.log.INFO.20161002-221612.35463 $LOGDIR
# $1 the line type
# $2 the name of saved image
#
#'supported_chart_types:',
#0 ['Test accuracy vs. Iters',
#1 'Test accuracy vs. Seconds',
#2 'Test learning rate vs. Iters',
#3 'Test learning rate vs. Seconds',
#4 'Test loss vs. Iters',
#5 'Test loss vs. Seconds',
#6 'Train learning rate vs. Iters',
#7 'Train learning rate vs. Seconds',
#8 'Train loss vs. Iters',
#9 'Train loss vs. Seconds']
./tools/extra/plot_training_log.py.example $1 $LOGDIR/$2 /Users/zhaomingming/Downloads/caffe-ssd/examples/cifar10/Log/caffe.zhaomac.lan.root.log.INFO.20161002-221612.35463
$1为线型,0表示 TestAccuracy vs. Iters,,, $2为图片名字,
将此代码保存为:train_plot.sh
运行办法:
sudo ./train_plot.sh 0 TestAccuracy.vs.Iters.png
输出图片如下: