始める無料で始める

学習曲線をプロットする

学習中、モデルは各エポックで評価された損失関数の値を保存します。学習曲線を見ることで、学習の進み方をかなり把握できます。この演習では、学習用にトレーニングするモデルについて、学習損失と検証損失の曲線をプロットします。

この演習はコースの一部です

Keras で学ぶ画像モデリング

コースを見る

演習の手順

  • モデルを学習用データ(train_data)に適合させます。
  • 検証分割は 20%、エポック数は 3、バッチサイズは 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()
コードを編集して実行