history = model.fit()
绘制训练损失和验证损失
import matplotlib.pyplot as plt loss = history.history[‘loss‘] val_loss = history.history[‘val_loss‘] epochs = range(1, len(loss) + 1) plt.plot(epochs, loss, ‘bo‘, label = ‘Training loss‘) plt.plot(epochs, val_loss, ‘b‘, label = ‘Validation loss‘) plt.title(‘Training And Validation Loss‘) plt.xlabel(‘Epochs‘) plt.ylabel(‘Loss‘) plt.legend() plt.show()
绘制训练精度和验证精度
plt.clf() acc = history.history[‘acc‘] val_acc = history.history[‘val_acc‘] plt.plot(epochs, acc, ‘bo‘, label = ‘Training acc‘) plt.plot(epochs, val_acc, ‘b‘, label = ‘Validation acc‘) plt.title(‘Training And Validation Accuracy‘) plt.xlabel(‘Epochs‘) plt.ylabel(‘Accuracy‘) plt.legend() plt.show()
原文地址:https://www.cnblogs.com/wbloger/p/10198365.html
时间: 2024-10-08 06:45:36