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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_36219202/article/details/78338920

根据训练后的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()

效果如下:
这里写图片描述

展开阅读全文

没有更多推荐了,返回首页