python art image training result loss diagram

And predict the resulting loss of accuracy of each epoch, the drawing can be seen that the convergence of the training results and the visual pleasure.

Coding #:. 8 UTF- 
Import matplotlib.pyplot AS PLT 

data_dir = "D: \\ the result.txt" 
Train_Loss_list = [] 
Train_Accuracy_list = [] 
Valid_Loss_list = [] 
Valid_Accuracy_list = [] 
F1 = Open (data_dir, 'R & lt') 
Data = [] 
# outputs the result to the training result.txt, the stupid way, pick up the digital results byte bits 
for F1 in Line: 
    IF (line.find ( 'train')> = 0): 
    # IF (to string.find has (Line, 'Train') = -1!): 
        Train_Loss_list.append (Line [12:18]) 
        Train_Accuracy_list.append (Line [24:30]) 
    IF (line.find ( 'Valid')> 0 =): 
    # IF (to string.find has (Line, 'Valid') = -1):! 
        Valid_Loss_list.append (Line [12:18]) 
        Valid_Accuracy_list.append(line[24:30]) 
f1.close () 
# iterated 30 times, the range of x (0,30), and then each time and the corresponding loss of accuracy on the x attached 
X1 = Range (0, 30) 
X2 Range = (0, 30) 
Y1 = Train_Accuracy_list 
Y2 = Train_Loss_list 
Y3 = Valid_Accuracy_list 
Y4 = Valid_Loss_list 
plt.subplot (2,. 1,. 1) 
# plt.plot (X1, Y1, 'O -', Color = 'R & lt') 
PLT .plot (X1, Y1, 'O -', label = "Train_Accuracy") 
plt.plot (X1, Y3, 'O -', label = "Valid_Accuracy") 
plt.title ( 'the Test Accuracy FC vs. Epoches') 
PLT .ylabel ( 'the Test Accuracy') 
plt.legend (LOC = 'Best') 
plt.subplot (2,. 1, 2) 
plt.plot (X2, Y2, '.-', label = "Train_Loss") 
plt.plot (X2, Y4, '.-', label = "Valid_Loss") 
PLT.xlabel('Test loss vs. epoches')
plt.ylabel('Test loss')
plt.legend (loc = 'best') 
plt.show ()

  

 

Guess you like

Origin www.cnblogs.com/marszhw/p/10962903.html