繪製損失值
在我們擬合模型之後,通常會檢查訓練損失曲線,確認它已經趨於平緩。model.fit() 回傳的 history 是一個字典,裡面有一個鍵 'loss',代表訓練損失。我們想確保在訓練尾端,損失大致上已經趨於平緩。
本練習屬於課程
Python 金融 Machine Learning
練習說明
- 從
history.history繪製損失值('loss')。 - 將圖表標題設為
history.history中最後一個損失值,並四捨五入到小數點後 6 位。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot the losses from the fit
plt.plot(____)
# Use the last loss as the title
plt.title('loss:' + str(round(____, 6)))
plt.show()