繪制學習模型的訓練損失和驗證損失圖形、繪制訓練精度和驗證精度圖形
阿新 • • 發佈:2018-12-30
atp div del bsp mat clas ali model hist
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()
繪制學習模型的訓練損失和驗證損失圖形、繪制訓練精度和驗證精度圖形