深度学习-根据日志画loss-acc折线图

根据训练后的log日志画训练的loss-acc折线图

import matplotlib.pyplot as plt
l_n = 0
a_n = 0
loss_x = []
loss_y = []
acc_x = []
acc_y = []
with open("/home/hytz/Downloads/Yifan/caffe-face/v2_log.txt") as f:   #根据自己的目录做对应的修改
    for line in f:
        line = line.strip()
        if len(line.split("accuracy = ")) == 2:
            acc_y.append(float(line.split("accuracy = ")[1]))
            acc_x.append(a_n)
            a_n += 100   #根据test_interval调整
        if len(line.split(" loss = ")) == 2:
            loss_y.append(float(line.split(" loss = ")[1]))  
            loss_x.append(l_n)
            l_n += 20   #根据display调整
print len(loss_x)       
plt.figure(figsize=(8,6))
plt.plot(loss_x,loss_y,'',label="loss")
plt.plot(acc_x,acc_y,'',label="acc")
plt.title('loss_acc')
plt.legend(loc='upper right')
plt.xlabel('iter')
plt.ylabel('')
plt.grid(loss_x)
plt.show()

效果如下:
深度学习-根据日志画loss-acc折线图_第1张图片

你可能感兴趣的:(深度学习)