用keras框架训练模型,画loss曲线

用keras框架训练模型,画loss曲线
训练中使用model.fit

history = model.fit(x_train, y_train, batch_size=16, epochs=10, validation_data=(x_test,y_test))

将history中的数值读出就行


epochs=range(len(history.history['acc']))
plt.figure()
plt.plot(epochs,history.history['acc'],'b',label='Training acc')
plt.plot(epochs,history.history['val_acc'],'r',label='Validation acc')
plt.title('Traing and Validation accuracy')
plt.legend()
plt.savefig('/root/notebook/help/figure/model_V3.1_acc.jpg')

plt.figure()
plt.plot(epochs,history.history['loss'],'b',label='Training loss')
plt.plot(epochs,history.history['val_loss'],'r',label='Validation val_loss')
plt.title('Traing and Validation loss')
plt.legend()
plt.savefig('/root/notebook/help/figure/model_V3.1_loss.jpg')

在这里插入图片描述

发布了46 篇原创文章 · 获赞 9 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43826596/article/details/101114737