绘制Loss对比曲线图

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=16)
def ReadTxtName(rootdir):
    lines = []
    with open(rootdir, 'r') as file_to_read:
        while True:
            line = file_to_read.readline()
            if not line:
                break
            line = line.strip('\n')
            lines.append(float(line))
    return lines

resultpath = r'C:\Users\411\Desktop\loss\pspnetloss.txt'   #四个网络loss值
resultpath2 = r'C:\Users\411\Desktop\loss\segnetloss.txt'
resultpath3 = r'C:\Users\411\Desktop\loss\unetloss.txt'
resultpath4= r'C:\Users\411\Desktop\loss\修改loss.txt'
lineslist = ReadTxtName(resultpath)
lineslist2 = ReadTxtName(resultpath2)
lineslist3 = ReadTxtName(resultpath3)
lineslist4 = ReadTxtName(resultpath4)


x=range(0,100)   #100
y1=lineslist
y2=lineslist2
y3=lineslist3
y4=lineslist4
plt.title('Result Analysis',fontproperties=font)
plt.plot(x, y1,color='black', label='Net1')    #四条曲线
plt.plot(x, y2, color='blue', label='Net2')
plt.plot(x, y3,color='red',label='Net3')
plt.plot(x, y4, color='green',label='improveNet')

plt.legend(prop=font) # 显示图例

plt.xlabel('Epoch',fontproperties=font)
plt.ylabel('Loss',fontproperties=font)
plt.show()

结果图

 

  • 7
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值