跳到主要内容Skip to main content

损失函数Loss Function

Loss Function

  • 核心概念Core concepts
  • 第四站 · 看懂Station 4 · Under the Hood
  • 引用核验 2026-11-17refs checked 2026-11-17
解决什么问题What problem it solves

把「预测得有多错」变成一个可求导的数值,训练就是把它压小。Turn “how wrong the prediction is” into a differentiable number; training minimises it.

这是什么What it is

不同任务用不同损失:分类常用交叉熵,回归常用均方误差,语言模型用下一 token 的交叉熵。

损失设计会改变模型学到的偏好,不只是优化技巧。

Different tasks use different losses: cross-entropy for classification, mean squared error for regression, next-token cross-entropy for language models.

Loss design changes what the model prefers. It is not merely an optimisation trick.

A loss turns the gap between prediction and target into a scalar; the optimizer uses its gradient to update parameters.
损失函数把预测与真值之间的差压成一个标量;训练器再用它的梯度更新参数。A loss turns the gap between prediction and target into a scalar; the optimizer uses its gradient to update parameters.
为什么需要知道Why it matters

指标和损失不是一回事;损失降了但业务指标不升很常见。Metrics and losses are not the same thing. A falling loss with a flat business metric is common.

别名Chinese aliases

loss · 目标函数 · 代价函数

出处Sources
  • PyTorch · 损失函数文档PyTorch loss functions ↗
  • Goodfellow 等 · Deep Learning 第 6 章Goodfellow et al., Deep Learning, Chapter 6 ↗