绘制损失
在拟合模型后,我们通常会检查训练损失曲线,以确认它是否已经趋于平稳。model.fit() 返回的 history 是一个字典,其中包含 'loss' 项,表示训练损失。我们要确保在训练结束时,这个值大致已经趋于平稳。
本练习是课程的一部分
Python 金融机器学习
练习说明
- 从
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()