开始使用免费开始使用

绘制学习曲线

在训练过程中,模型会在每个 epoch 记录一次损失函数值。查看学习曲线可以帮助我们了解训练过程。在本练习中,您将为即将训练的模型绘制训练损失曲线和验证损失曲线。

本练习是课程的一部分

使用 Keras 进行图像建模

查看课程

练习说明

  • 将模型拟合到训练数据(train_data)。
  • 使用 20% 的验证拆分,训练 3 个 epoch,批量大小为 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()
编辑并运行代码