開始使用免費開始

繪製學習曲線

在學習過程中,模型會在每個 epoch 儲存一次損失函式的評估值。觀察學習曲線能幫助我們理解學習的情形。在這個練習中,你將為自己訓練的模型繪製訓練與驗證損失的曲線。

本練習屬於課程

使用 Keras 進行影像建模

檢視課程

練習說明

  • 將模型擬合至訓練資料(train_data)。
  • 使用 20% 的驗證切分、3 個 epoch,以及 batch size 為 10。
  • 繪製訓練損失。
  • 繪製驗證損失。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

import matplotlib.pyplot as plt

# Train the model and store the training object
training = ____

# Extract the history from the training object
history = training.____

# Plot the training loss 
plt.plot(history[____])
# Plot the validation loss
plt.plot(history[____])

# Show the figure
plt.show()
編輯並執行程式碼