Training needs a score. The loss function measures how wrong a model's predictions are, giving the optimizer something to minimize. Cross-entropy for classification. Mean squared error for regression. Custom losses for specialized tasks.
The choice shapes behaviour. A model trained on cross-entropy learns calibrated probabilities. One trained on hinge loss learns a margin. Two models with identical architectures and data can behave very differently depending on what you ask them to minimize.
Common loss functions
- Mean squared error for regression
- Cross-entropy for classification
- Hinge loss for margin-based classifiers
- Contrastive loss for embeddings
- Triplet loss for similarity learning
Imbalanced data complicates loss. A classifier trained on cross-entropy will favour the majority class unless weights are adjusted. Focal loss and class weighting address the issue, at the cost of additional tuning.
Comments (3)
Leave a comment