loss function
A loss function is a function that returns a scalar measuring the discrepancy between a model’s predictions and the target data, providing the signal that guides the parameter updates during training.
Common choices include mean squared error for regression, cross-entropy or negative log-likelihood for classification, and margin-based or contrastive objectives for ranking and metric learning.
The training objective often combines a task loss with regularization terms to control complexity. Properties such as differentiability, calibration behavior, and robustness to outliers influence optimization dynamics and generalization. Variants like class weighting, focal loss, or label smoothing adapt the signal to data imbalance or noise.
Related Resources
Tutorial
Stochastic Gradient Descent Algorithm With Python and NumPy
In this tutorial, you'll learn what the stochastic gradient descent algorithm is, how it works, and how to implement it with Python and NumPy.
For additional information on related topics, take a look at the following resources:
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Leodanis Pozo Ramos • Updated Sept. 17, 2026