File size: 854 Bytes
e1810a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from matplotlib import pyplot as plt
def Plt(file):
filereader = open(file.name, 'r')
# 可视化
Loss_list = []
Accuracy_list = []
for line in filereader.readlines():
if line[0:4] == "loss":
list = line.split()
# print(list[1])
Loss_list.append(float(list[1]))
Accuracy_list.append(float(list[3]))
print(Loss_list)
length = len(Loss_list)
x1 = range(0, length)
x2 = range(0, length)
y1 = Accuracy_list
# y2 = Loss_list[4:]
y2 = Loss_list
plt.subplot(2, 1, 1)
plt.plot(x1, y1)
plt.title('Test accuracy vs. epoches')
plt.ylabel('Test accuracy')
plt.subplot(2, 1, 2)
plt.plot(x2, y2)
plt.xlabel('Test loss vs. epoches')
plt.ylabel('Test loss')
plt.savefig("result.jpg")
# plt.show()
return "result.jpg"
|