Skip to main content

Loss Function

Loss Function

  • Core concepts
  • Stage 4 · Under the Hood
  • refs checked 2026-11-17
What problem it solves

Turn “how wrong the prediction is” into a differentiable number; training minimises it.

What it is
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

Sources
  • PyTorch loss functions ↗
  • Goodfellow et al., Deep Learning, Chapter 6 ↗
Use this term in a task

Don’t stop at the definition: use the task handbook for the order and checks, or filter three tool candidates for the job at hand.

Task handbooks → · Filter three candidates →