先贴一下自己的log文件的截图
这里以score_loss为例
代码如下
from matplotlib import rcParams
import matplotlib.pyplot as plt
import re
##显示中文
rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = 'SimSun,Times New Roman'
text = ''
file = open('log.txt') ##我的log.txt文件是放在了和python文件同级别目录下
for line in file:
text += line
file.close()
all_list = re.findall('loss: .*[0-9]',text)
train_loss = []
for i in all_list:
train_loss.append(float(i.split('score_loss: ')[1].split(', grouperr:')[0]))
##分割出score_loss的数值
plt.plot(train_loss,label='score_loss')
plt.legend(loc='best')
plt.show()