栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

绘制Loss对比曲线图

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

绘制Loss对比曲线图

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:windowsfontsSimSun.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:Users411Desktoplosspspnetloss.txt'   #四个网络loss值
resultpath2 = r'C:Users411Desktoplosssegnetloss.txt'
resultpath3 = r'C:Users411Desktoplossunetloss.txt'
resultpath4= r'C:Users411Desktoploss修改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()

结果图

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/286673.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号