一、代码
# encoding: utf-8
import matplotlib.pyplot as plt
file = open('train_cc_kl_11_20.txt') #打开文档
data = file.readlines() #读取文档数据
itr = [] #新建列表,用于保存第一列数据
train_loss = [] #新建列表,用于保存第二列数据
train_loss0 = []
train_cc = []
train_kl = []
train_ssim = []
train_iou = []
for num in data:
# split用于将每一行数据用逗号分割成多个对象
#取分割后的第0列,转换成float格式后添加到para_1列表中
itr.append(float(num.split(' ')[1]))
#取分割后的第1列,转换成float格式后添加到para_1列表中
train_loss.append(float(num.split(' ')[3]))
train_loss0.append(float(num.split(' ')[5]))
train_cc.append(float(num.split(' ')[7]))
train_kl.append(float(num.split(' ')[9]))
train_ssim.append(float(num.split(' ')[11]))
train_iou.append(float(num.split(' ')[13]))
plt.figure()
plt.title('loss')
plt.plot(itr, train_loss , color='green', label='train_loss')
plt.plot(itr, train_loss0, color='red', label='train_loss0')
plt.plot(itr, train_cc, color='yellow', label='train_cc')
plt.plot(itr, train_kl, color='blue', label='train_kl')
plt.plot(itr, train_ssim, color='black', label='train_ssim')
plt.plot(itr, train_iou, color='skyblue', label='train_iou')
plt.xlabel('itr_num')
plt.ylabel('loss')
plt.legend() # 显示图例
plt.savefig('train_cc_kl_11_20.jpg')
plt.show()
二、txt文档
ite_num 1 train_loss 20.489668 train_loss0 2.678142 train_cc -0.071388 train_kl 1.224694 train_ssim 0.971022 train_iou 0.942812
ite_num 2 train_loss 19.264322 train_loss0 2.593349 train_cc -0.249546 train_kl 1.647639 train_ssim 0.944111 train_iou 0.958094
ite_num 3 train_loss 18.457757 train_loss0 2.475785 train_cc 0.131888 train_kl 1.293301 train_ssim 0.889473 train_iou 0.944845
ite_num 4 train_loss 17.644971 train_loss0 2.359065 train_cc 0.095214 train_kl 1.067395 train_ssim 0.753031 train_iou 0.943677
ite_num 5 train_loss 16.980869 train_loss0 2.275879 train_cc 0.164072 train_kl 1.271030 train_ssim 0.751877 train_iou 0.958184
ite_num 6 train_loss 16.494543 train_loss0 2.215926 train_cc 0.111663 train_kl 1.342100 train_ssim 0.730752 train_iou 0.961605
ite_num 7 train_loss 16.155186 train_loss0 2.166233 train_cc 0.249840 train_kl 1.295280 train_ssim 0.689702 train_iou 0.953053
ite_num 8 train_loss 15.817177 train_loss0 2.120727 train_cc 0.255999 train_kl 1.467050 train_ssim 0.637748 train_iou 0.958292
ite_num 9 train_loss 15.600094 train_loss0 2.080656 train_cc 0.312536 train_kl 1.181383 train_ssim 0.549416 train_iou 0.946675
ite_num 10 train_loss 15.302359 train_loss0 2.040154 train_cc 0.559948 train_kl 0.860402 train_ssim 0.525284 train_iou 0.955916
ite_num 11 train_loss 15.162563 train_loss0 2.011776 train_cc 0.204101 train_kl 1.517152 train_ssim 0.485285 train_iou 0.956931
ite_num 12 train_loss 14.986349 train_loss0 1.979289 train_cc 0.358850 train_kl 1.280727 train_ssim 0.417952 train_iou 0.951432
ite_num 13 train_loss 14.759432 train_loss0 1.941175 train_cc 0.439954 train_kl 0.937002 train_ssim 0.360004 train_iou 0.945832
ite_num 14 train_loss 14.589410 train_loss0 1.912967 train_cc 0.443144 train_kl 1.174112 train_ssim 0.380660 train_iou 0.946853
|