The loss function measures how wrong the model's predictions are. Training minimizes it via Backpropagation.
Regression:
Mean Squared Error (MSE):
- Equivalent to MLE assuming Gaussian noise
- Penalizes large errors quadratically → sensitive to outliers
- Gradient:
Classification:
Binary cross-entropy:
- Equivalent to negative log-likelihood of Bernoulli distribution
- Used with sigmoid output
Categorical cross-entropy:
- Equivalent to negative log-likelihood of categorical distribution
- Used with softmax output
- One-hot : simplifies to where is the true class
Connection: minimizing cross-entropy = minimizing KL Divergence from the true distribution (since and is constant).
In LLM pretraining: cross-entropy on next-token prediction is the standard objective → Pretraining.
See also: Maximum Likelihood Estimation, Logistic Regression