用keras框架训练模型,画loss曲线
训练中使用model.fit
history = model.fit(x_train, y_train, batch_size=16, epochs=10, validation_data=(x_test,y_test))
1
将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’)
————————————————
版权声明:本文为CSDN博主「恋上萤火」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43826596/article/details/101114737