# -*- coding: utf-8 -*- """ Created on Fri Sep 7 18:38:35 2018 @author: manuel """ import matplotlib.pyplot as plt #from mpl_toolkits.axisartist.axislines import SubplotZero import numpy as np plt.rcParams['font.sans-serif']=['SimHei'] # 用来正常显示中文标签 plt.rcParams['axes.unicode_minus']=False # 用来正常显示负号 SAVE_LOSS0='HG_loss.txt' #SAVE_LOSS1='hotrolledsteel1800_20_20_2000_10_loss.txt' #SAVE_LOSS2='hotrolledsteel1800_20_20_2000_50_loss.txt' #SAVE_LOSS3='hotrolledsteel1800_20_20_2000_100_loss.txt' SAVE_VALIDATION_ACCURACY='HG_validation_accuracy.txt' #x = np.linspace(0, 2, 100) #plt.plot(x, x, label='linear') #plt.plot(x, x**2, label='quadratic') #plt.plot(x, x**3, label='cubic') with open(SAVE_LOSS0, 'r') as open_file0: file_string0 = open_file0.read() file_values0 = [float(x) for x in file_string0.split(',')] with open(SAVE_VALIDATION_ACCURACY, 'r') as open_file1: file_string1 = open_file1.read() file_values1 = [float(x) for x in file_string1.split(',')] #with open(SAVE_LOSS2, 'r') as open_file2: # file_string2 = open_file2.read() #file_values2 = [float(x) for x in file_string2.split(',')] # #with open(SAVE_LOSS3, 'r') as open_file3: # file_string3 = open_file3.read() #file_values3 = [float(x) for x in file_string3.split(',')] epoches=[i for i in range(len(file_values0))] #plt.plot(epoches, file_values0, label='2000X5',color='black')#darkgray #plt.plot(epoches, file_values1, label='2000X10',color='black') #plt.plot(epoches, file_values2, label='2000X50',color='black')#darkgray plt.plot(epoches, file_values0,'r-',markersize=1,linewidth=1,label="loss") plt.plot(epoches, file_values1,'b-',markersize=1,linewidth=1,label="accuracy") plt.plot(np.linspace(1,1,1000),color='black',linestyle='--') plt.xlabel("epoches(迭代次数)") plt.ylabel("Loss/Accuracy(损失值/准确率)") #plt.xticks(range(0,2000,100)) #fig,ax_y2=plt.subplot() #ax_c=ax_y2.twiny() #ax_c.set_ylabel('第二Y轴', color='b') #ax_c.set_yticklabels(["$0$", r"$\frac{1}{2}\pi$", r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"]) #plt.ylabel("Validation Accuracy") #plt.axis([0, 2000, 0, 100]) plt.title("Training dataset(训练集)/Learning Rate=0.015 Batch=64") plt.legend() plt.show() #!!!间隔描点未解决