Watch it overfit · polynomial regression with ridge (L2)
L1 vs L2 · why one zeros weights and the other just shrinks them
The optimal weights sit at the center of the loss ellipses. Regularization forces the solution to live inside a budget region. Where the ellipse first touches that region is the regularized answer.
L2 (circle): smooth boundary → the contact point usually has both weights small but non-zero. Shrinks everything toward zero. This is "weight decay" — the most common regularizer.
L1 (diamond): sharp corners on the axes → the ellipse tends to touch at a corner, where one weight is exactly 0. L1 produces sparse models — automatic feature selection.
Dropout · randomly silence neurons during training
Inference: all neurons active, outputs scaled by (1−p) so the expected signal matches. No randomness at test time.
The full toolbox
| METHOD | HOW | EFFECT |
|---|---|---|
| L2 / weight decay | add λ‖w‖² to loss | shrinks all weights; smoother function |
| L1 / Lasso | add λ‖w‖₁ to loss | drives weights to exactly 0 → sparse |
| Dropout | randomly zero activations | prevents co-adaptation; ensemble effect |
| Batch / Layer Norm | normalize activations per batch/layer | stabilizes training; mild regularizer |
| Early stopping | halt when val loss stops improving | free; stops before memorization |
| Data augmentation | flip/crop/jitter inputs | more effective data → less overfit (see Aug Lab) |
| Label smoothing | soften one-hot targets | less over-confidence; better calibration |