Regularization (L1, L2, Dropout, Early Stopping)
Q: How does regularization reduce overfitting? L1 vs L2?
Add a penalty that discourages complex solutions: loss = data_loss + λ·R(w).
- L2 (ridge / weight decay):
R = Σw²→ shrinks all weights smoothly; equivalent to a Gaussian prior; handles correlated features well. - L1 (lasso):
R = Σ|w|→ drives weights exactly to zero (sparse, feature selection); Laplace prior. The L1 ball has corners on the axes, where the loss contours tend to touch it. - Elastic net: mix of both.
- Dropout: randomly zero activations during training (scale by
1/(1−p)); trains an implicit ensemble and prevents co-adaptation. - Early stopping: stop when validation loss stops improving.
- Data augmentation, label smoothing, noise injection also regularize.
w2 w2
| L2 ball (circle) | L1 ball (diamond)
.-+-. contours /\ contours touch at
( + ) touch anywhere / +\ a corner -> w1 = 0
'-+-' -> small w1, w2 \ + / (sparse)
| \/