§7.1.2 L¹ regularization — the road to sparsity
Swap the squared L² norm for the L¹ norm and the behavior changes qualitatively. The whole difference is visible in the (sub-)gradient:
Term by term
| the L¹ contribution: a CONSTANT-magnitude pull toward zero, the same size whether wᵢ is 0.01 or 100 — it does NOT scale with the weight | constant pull | |
| L² instead pulls proportionally to wᵢ, so it eases off as the weight shrinks and never quite reaches zero | the contrast | |
| the ordinary data-loss gradient | data term |
Assume (as the book does) that the inputs were decorrelated so the Hessian is diagonal, with . Then the regularized objective decouples into one independent scalar problem per weight, each with a clean closed form:
step 1/3: Quadratic approximation with a DIAGONAL Hessian: the cost splits into a sum of independent per-weight terms, so each wᵢ can be optimized on its own.
Compare the two side by side — L¹ has a dead zone that zeroes small weights, while L² only rescales:
Any w*ᵢ inside the shaded band |w*ᵢ| ≤ α/H is driven to exactly zero by L¹ — that is sparsity. L² only scales every weight by the same factor, so nonzero weights stay nonzero.
For L², revisiting eq 7.13 under the same diagonal Hessian gives : if was nonzero, stays nonzero. So L² never makes weights sparse; L¹ can. That sparsity is used for feature selection — the famous LASSO lasso Least Absolute Shrinkage and Selection Operator (Tibshirani 1995): an L¹ penalty + linear model + least-squares cost; the zeroed weights perform automatic feature selection. defined in ch. 7 — open in glossary pairs an L¹ penalty with least squares, and the weights driven to zero mark features that can be discarded.
Both norms are priors (MAP Bayesian view)
From §5.6.1, regularizers are MAP Bayesian inference. L² l2 regularization Weight decay: Ω = ½‖w‖₂². Shrinks each Hessian-eigencomponent of w* by λᵢ/(λᵢ+α), decaying low-curvature (unimportant) directions while preserving high-curvature ones. defined in ch. 7 — open in glossary is MAP with a Gaussian prior on the weights (smooth, keeps everything small); L¹ l1 regularization Penalty α‖w‖₁ = αΣ|wᵢ|. Its constant-magnitude sub-gradient α·sign(w) soft-thresholds weights to EXACTLY zero, inducing sparsity — unlike L², which only shrinks proportionally. defined in ch. 7 — open in glossary is MAP with an isotropic Laplace laplace prior (map view) L¹ regularization equals MAP inference with an isotropic Laplace prior on the weights — just as L² equals MAP with a Gaussian prior. defined in ch. 7 — open in glossary prior, whose sharp peak at zero is exactly what pushes weights to stick at zero.
§7.2 Norm penalties as constrained optimization
A penalty and a hard constraint are two views of the same thing. To force , build a generalized Lagrangian:
Term by term
| the KKT multiplier; it must grow whenever Ω(θ) > k and shrink whenever Ω(θ) < k, enforcing the budget | KKT multiplier | |
| the constraint: penalize only the amount by which the norm exceeds the budget k | constraint | |
| freeze α at its optimum and this is EXACTLY the penalized problem argmin J + α*Ω — a penalty confines w to a region, larger α ⇒ smaller region | equivalence |
So weight decay confines to a ball. Which region is set by the norm — and this is where L¹’s sparsity becomes geometric. Morph the unit ball below: L²’s smooth circle meets the objective anywhere, but L¹’s diamond has corners on the axes, and the constrained optimum tends to land on a corner — where some coordinates are exactly zero:
‖x‖2 = 0.960
The shaded region is the unit ball ‖x‖ₚ ≤ 1. At p = 1 it has corners ON the axes — the geometric seed of L¹'s preference for exact zeros (§7.1 builds on this).
Sometimes use a hard constraint, not a penalty
You can instead take an SGD step then reproject explicit constraint & reprojection Take an SGD step then PROJECT θ back onto Ω(θ) < k. Avoids the dead-unit local minima and runaway-weight feedback that soft penalties can cause; used for Hinton column-norm constraints. defined in ch. 7 — open in glossary back onto . Three reasons to prefer this: (1) if you know a good , you skip searching for the matching ; (2) penalties can trap non-convex training in dead-unit minima (small-weight solutions) — reprojection never pushes weights toward the origin, so it avoids them; (3) it adds stability, killing the positive-feedback loop where big weights → big gradients → bigger weights → overflow. Hinton’s column-norm constraint (cap each weight-matrix column) is the classic example, always done by reprojection.
§7.3 Regularization for under-constrained problems
Sometimes regularization is not optional — it is what makes the problem well-defined. Many linear models (linear regression, PCA) invert , which is singular when a direction has no variance or when there are fewer examples than features. Adding the penalty inverts instead — always invertible. Likewise, logistic regression on linearly separable data under-constrained problem A problem where XᵀX is singular or the optimum diverges (e.g. logistic regression on linearly separable data); regularization (invert XᵀX+αI, or weight decay) makes it well-defined and convergent. defined in ch. 7 — open in glossary has no finite optimum (if separates the classes, so does with higher likelihood), so SGD drives until overflow; weight decay halts it. This connects to a familiar object:
Term by term
| exactly the linear-regression-with-weight-decay solution from §7.1.1 (eq 7.17) | ridge solution | |
| let the regularization vanish | zero-α limit | |
| the Moore–Penrose pseudoinverse (§2.9) — so the pseudoinverse IS weight decay in the limit, stabilizing otherwise ill-posed problems | the identity |
§7.4 Dataset augmentation
The best way to generalize better is more data — so make fake data. This is easiest for classification: a classifier must be invariant to many transforms of , so generate new pairs by transforming the inputs. For object recognition, translating an image a few pixels, rotating, or scaling it yields large gains. The one rule: never apply a transform that changes the correct label. Toggle the transforms below — three are safe, one is a trap:
Toggle transforms of the input. Label after transform:
Translate, small-rotate and scale are safe — they teach the classifier invariance for free. The 180° rotation is the trap: it maps a 6 to a 9, so training on it would teach the wrong label.
Some invariances are hard to synthesize (out-of-plane rotation is not a pixel operation), but augmentation also helps speech recognition. Crucially, injecting noise noise injection Adding random noise to inputs (≈ a weight-norm penalty), to weights (≈ flat-minima / Bayesian uncertainty), or to hidden units (dropout) as a form of regularization / augmentation. defined in ch. 7 — open in glossary into the inputs is itself a form of augmentation: neural nets are surprisingly fragile to input noise, so training with it improves robustness (this is the idea behind the denoising autoencoder, and — applied to hidden units — behind dropout). One caveat for fair benchmarking: because augmentation can dramatically cut error, comparing two algorithms is only valid when both use the same augmentation scheme.
Next: noise robustness proper, label smoothing, semi-supervised and multi-task learning — noise, semi-supervised & multi-task.
Check yourself — L¹ sparsity, constraints, under-constrained problems, augmentation
1.Why does L¹ regularization produce sparsity (exact zeros) while L² does not?
2.In SoftThresholdLab with α = 1.5 and H = 1.5 (so α/H = 1), what does L¹ do to a weight with w*ᵢ = 0.6?
3.How is a parameter norm penalty αΩ(θ) equivalent to a constrained optimization problem?
4.What is the relationship between the Moore–Penrose pseudoinverse and weight decay?
5.In AugmentLab, why is the 180° rotation flagged as unsafe while translate/scale/small-rotate are fine?