Contents
L1 vs L2 Regularization and Early Stopping/Chapter 12 of 12
12Summary
- Regularized objective: J(w)=\|y-Xw\|_2^2+\lambda\,\Omega(w). \lambda trades bias for variance and is chosen by cross-validation. Some \lambda>0 always beats least squares (Theorem 1).
- L2 (ridge, weight decay): \Omega=\|w\|_2^2, gradient 2\lambda w (spring), \hat w=(X^\top X+\lambda I)^{-1}X^\top y, shrinkage d_j/(d_j+\lambda) per eigen-direction, \mathrm{df}(\lambda)=\sum_jd_j/(d_j+\lambda); no exact zeros; Gaussian prior, \lambda=\sigma^2/\tau^2.
- L1 (lasso): \Omega=\|w\|_1, push \lambda\operatorname{sign}(w) (flat tax); orthonormal solution S_{\lambda/2}(\hat w)=\operatorname{sign}(\hat w)(|\hat w|-\lambda/2)_+; w_j=0 iff |2x_{\cdot j}^\top(y-Xw)|\le\lambda; \lambda_{\max}=2\max_j|x_{\cdot j}^\top y|; coordinate descent; Laplace prior, \lambda=2\sigma^2/b.
- Geometry: penalty \Leftrightarrow budget \Omega(w)\le t; the diamond’s corners lie on the axes, so contact at a corner gives zeros; the disc is smooth.
- Elastic net: \lambda_1\|w\|_1+\lambda_2\|w\|_2^2: sparse, unique, keeps correlated groups together.
- Early stopping: stop at the validation minimum (patience, restore the best weights); filter factor 1-(1-\eta h)^\tau versus h/(h+2\lambda), so \lambda\approx1/(2\eta\tau).
- L2 in disguise: input noise of variance s^2 = ridge with \lambda=ns^2; dropout with keep probability p = ridge with \lambda_j=\frac{1-p}{p}\sum_iX_{ij}^2; weight decay = L2 for SGD but not for Adam (AdamW).
- Practice: standardize, do not penalize the intercept, cross-validate \lambda on a log grid, test once.