PyTorch入门学习:2-Linear Model

1 示例

1.1 Training Set & Test Set(泛化能力)

alt text 数据集划分为训练集和测试集,而为了测试集的表现较好,又将训练集划分为训练集和验证集。

1.2 Model design

示例中的数据明显适用线性模型,即 y = wTx + b。 Training Loss 定义为模型在训练集上的损失函数值,即 $$ L(w, b) = \sum_{i=1}^n (y_i - (w^Tx_i + b))^2 $$

alt text alt text 随着训练轮数的增加,Training Loss 会逐渐减小,但 Validation Loss 会先减小后增大,这是因为模型在训练集上的损失函数值会减小,但是在验证集上的损失函数值会先减小后增大,这说明模型在验证集上的表现开始变差。 > 在深度学习中经常使用可视化工具来展示模型的训练过程和性能。

1.3 Exercise

  • Try to use the model in right-sight, and draw the cost graph.

PyTorch入门学习:2-Linear Model
https://eleco.top/2026/02/23/learn-torch-2-Linear-Model-md/
作者
Eleco
发布于
2026年2月23日
许可协议