赞
踩
import matplotlib.pyplot as plt from matplotlib.pyplot import MultipleLocator # 创建第一张画布 plt.figure(0) # 绘制训练损失曲线 plt.plot(all_train_losses, label="Train Loss") # 绘制验证损失曲线, 颜色为红色 plt.plot(all_valid_losses, color="red", label="Valid Loss") # 定义横坐标刻度间隔对象, 间隔为1, 代表每一轮次 x_major_locator=MultipleLocator(1) # 获得当前坐标图句柄 ax=plt.gca() # 设置横坐标刻度间隔 ax.xaxis.set_major_locator(x_major_locator) # 设置横坐标取值范围 plt.xlim(1,epochs) # 曲线说明在左上方 plt.legend(loc='upper left') # 保存图片 plt.savefig("./loss.png") # 创建第二张画布 plt.figure(1) # 绘制训练准确率曲线 plt.plot(all_train_acc, label="Train Acc") # 绘制验证准确率曲线, 颜色为红色 plt.plot(all_valid_acc, color="red", label="Valid Acc") # 定义横坐标刻度间隔对象, 间隔为1, 代表每一轮次 x_major_locator=MultipleLocator(1) # 获得当前坐标图句柄 ax=plt.gca() # 设置横坐标刻度间隔 ax.xaxis.set_major_locator(x_major_locator) # 设置横坐标取值范围 plt.xlim(1,epochs) # 曲线说明在左上方 plt.legend(loc='upper left') # 保存图片 plt.savefig("./acc.png")
训练和验证损失对照曲线
训练和验证准确率对照曲线:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。