cv-画loss图

用loss.txt画loss图

import matplotlib.pyplot as plt
import scipy


def plot_loss(fileName):
    print("Start to plot loos line")
    allData = [] 
    file = open(fileName)
    fileData = file.readlines()
    for row in fileData:
        lineData = row[:-1]
        allData.append(float(lineData))

    
    allData = scipy.signal.savgol_filter(allData, 21, 3) 
    plt.plot(allData)
    plt.xlabel('Iteration')
    plt.ylabel('Loss') 
    label = ['train loss']
    plt.legend(label, loc='upper right')
    plt.savefig('./loss.png')
    print(allData[-10:])
posted @ 2022-11-01 15:49  starc的miao  阅读(44)  评论(0)    收藏  举报