§7.0 What regularization is really trading
Chapter 6 gave us powerful function approximators. Now the problem flips: a model with enough capacity to fit the training set will also fit its noise. Regularization regularization Any modification intended to reduce generalization error but not training error — preferences among hypothesis-space members (e.g. weight decay λwᵀw). defined in ch. 5 — open in glossary is “any modification we make to a learning algorithm that is intended to reduce its generalization error but not its training error.” Almost every strategy in this chapter buys lower test error at the price of higher training error — and that is exactly the point.
The mechanism is the bias–variance trade bias-variance trade-off MSE = Bias² + Variance: capacity ↑ typically bias ↓ variance ↑ — the U-curve again; negotiated by cross-validation. defined in ch. 5 — open in glossary : regularizing an estimator increases bias to reduce variance. An effective regularizer makes a profitable trade — cutting variance a lot while adding only a little bias. Chapter 5 framed three regimes: the model family (1) excludes the true process (underfitting, high bias), (2) matches it, or (3) contains it plus many other processes (overfitting, high variance). Regularization aims to move a model from regime 3 into regime 2.
Why the biggest model, then rein it in
In real deep learning the true data-generating process is almost never in our model family — generating natural images or speech would mean simulating the world. We are always fitting a square peg (the true process) into a round hole (our model family). So controlling complexity is not a matter of finding the model with exactly the right number of parameters. In practice the best-generalizing model is a large model that has been regularized well — not a small unregularized one. That reframing motivates the whole chapter.
§7.1 Parameter norm penalties
The oldest and simplest family adds a parameter norm penalty parameter norm penalty A term αΩ(θ) added to the objective (J̃ = J + αΩ) that limits capacity by penalizing weight size; α∈[0,∞) sets the strength. Only weights are penalized, not biases. defined in ch. 7 — open in glossary to the objective:
Term by term
| the ordinary training objective (e.g. cross-entropy) — fits the data | data fit | |
| the penalty on parameter size — a measure of model complexity to be kept small | penalty | |
| the strength knob: α=0 is no regularization, larger α means more. Minimizing J̃ decreases BOTH the data loss and the parameter size | hyperparameter |
Penalize weights, never biases
We write for the weights that get penalized and for all parameters. A weight couples two variables, so fitting it well needs to observe both under many conditions — it is variance-prone and worth regularizing. A bias controls a single variable, needs little data to fit, and penalizing it tends to cause underfitting. So the penalty touches weights only. (You could use a different α per layer, but searching many coefficients is expensive, so one shared α is common.)
§7.1.1 L² regularization (weight decay)
The most common penalty is the L² norm, — L² regularization 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 , better known as weight decay weight decay The L² regularizer: J = MSE + λwᵀw; trades data fit against small weights; = MAP with a Gaussian prior; = ch4's constrained optimization. defined in ch. 5 — open in glossary (and, elsewhere, ridge regression or Tikhonov regularization ridge regression / tikhonov regularization Other-community names for L² parameter regularization (weight decay). defined in ch. 7 — open in glossary ). Look at what it does to a single gradient step (assume ):
Term by term
| the NEW part: before the usual update, the weight vector is multiplicatively shrunk toward the origin by a constant factor each step | the “decay” | |
| the ordinary gradient-descent step on the data loss, unchanged | usual step | |
| learning rate; the shrink factor 1−εα is just under 1 for small α | step size |
That is one step. To see the effect over all of training, approximate by a quadratic bowl around the unregularized optimum and solve for where weight decay moves the minimum:
step 1/7: Second-order Taylor approximation of J around the unregularized minimum w*. There is no first-order term because the gradient vanishes at a minimum, and H (the Hessian at w*) is positive semidefinite.
The picture: weight decay rescales along the eigenvectors of the Hessian. Directions the objective cares about (large ) barely move; directions it is indifferent to (small ) get shrunk to nearly zero. Drag , , and watch the equilibrium slide between the objective’s optimum and the origin:
The axis with the smaller eigenvalue (lower curvature — the objective barely changes there) gets shrunk toward zero; the high-curvature axis is almost untouched. Raise α to pull w̃ toward the origin; the low-λ coordinate collapses first.
Reading the equilibrium
At the two gradients cancel: the objective pulls toward (solid arrow), the regularizer pulls toward the origin (dotted arrow). Along the flat axis the objective hardly resists, so the regularizer wins and that coordinate collapses; along the steep axis the objective resists strongly, so weight decay barely dents it. Only directions that genuinely reduce the loss survive.
The linear-regression special case
For linear regression the cost is truly quadratic, so the analysis is exact. Weight decay changes the normal equations by adding to the diagonal:
Term by term
| proportional to the input covariance (1/m)XᵀX — its diagonal entries are the variances of the input features | covariance | |
| weight decay adds α to every diagonal entry — the model “perceives” each input as having higher variance | the fix | |
| so it shrinks the weights on features whose covariance with the output is low compared to α — noisy/irrelevant features are down-weighted | the effect |
Next: L¹ regularization (which makes weights exactly zero), norm penalties as constrained optimization, and dataset augmentation — L¹, constraints & augmentation.
Check yourself — the bias–variance trade and L² weight decay
1.What trade does regularization make, and what is an 'effective' regularizer?
2.Why does the parameter norm penalty regularize the weights w but leave the biases unpenalized?
3.Weight decay rescales the component of w* along the i-th Hessian eigenvector by λᵢ/(λᵢ+α). What happens along a LOW-curvature direction (small λᵢ)?
4.In WeightDecayLab, set λ₁ = 0.4 (flat axis), λ₂ = 3 (steep axis), and raise α from 0. Which coordinate of w̃ collapses toward zero first?
5.For linear regression, L² regularization changes the solution to w = (XᵀX + αI)⁻¹Xᵀy. What is the intuitive effect of the +αI?