用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')

用keras框架训练模型,画loss曲线_第1张图片

你可能感兴趣的:(深度学习)