§7.1.2–7.4L¹ Regularization & Sparsity · Norm Penalties as Constraints · Under-Constrained Problems · Dataset Augmentation

Part II DL pp. 234–241 · ~6 min read

  • l1 regularization
  • soft-thresholding
  • lasso
  • norm penalty as constrained optimization
  • under-constrained problem
  • dataset augmentation

§7.1.2 L¹ regularization — the road to sparsity

Swap the squared L² norm for the L¹ norm Ω(θ)=w1=iwi\Omega(\boldsymbol{\theta}) = \lVert\boldsymbol{w}\rVert_1 = \sum_i |w_i| and the behavior changes qualitatively. The whole difference is visible in the (sub-)gradient:

Term by term

wJ~(w;X,y)=αsign(w)+wJ(w;X,y)\nabla_{\boldsymbol{w}} \tilde{J}(\boldsymbol{w}; \boldsymbol{X}, \boldsymbol{y}) = \alpha\,\mathrm{sign}(\boldsymbol{w}) + \nabla_{\boldsymbol{w}} J(\boldsymbol{w}; \boldsymbol{X}, \boldsymbol{y})
αsign(w)\alpha\,\mathrm{sign}(\boldsymbol{w})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 weightconstant pull
vs αw (L2)\text{vs } \alpha\boldsymbol{w}\ (L^2)L² instead pulls proportionally to wᵢ, so it eases off as the weight shrinks and never quite reaches zerothe contrast
wJ\nabla_{\boldsymbol{w}} Jthe ordinary data-loss gradientdata term

Assume (as the book does) that the inputs were decorrelated so the Hessian is diagonal, H=diag(H1,1,,Hn,n)\boldsymbol{H} = \mathrm{diag}(H_{1,1},\dots,H_{n,n}) with Hi,i>0H_{i,i}>0. Then the regularized objective decouples into one independent scalar problem per weight, each with a clean closed form:

The L¹ solution is soft-thresholding (equations 7.22–7.23)
J^(w)=J(w)+i[12Hi,i(wiwi)2+αwi]\hat{J}(\boldsymbol{w}) = J(\boldsymbol{w}^*) + \sum_i \left[ \tfrac12 H_{i,i}(w_i - w_i^*)^2 + \alpha |w_i| \right]

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:

L¹ soft-threshold (dead zone → exact zeros) vs L² proportional shrink, as a function of the unregularized weight w*ᵢ
w*ᵢwᵢwᵢ = w*ᵢα/H−α/H
L¹ — soft-threshold (sparse) L² — proportional shrink
threshold α/H = 0.67
L² factor H/(H+α) = 0.60
L¹ → 0.00zeroed
L² → 0.36

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 w~i=Hi,iHi,i+αwi\tilde w_i = \frac{H_{i,i}}{H_{i,i}+\alpha}w_i^*: if wiw_i^* was nonzero, w~i\tilde w_i stays nonzero. So L² never makes weights sparse; L¹ can. That sparsity is used for feature selection — the famous LASSO 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. is MAP with a Gaussian prior on the weights (smooth, keeps everything small); is MAP with an isotropic Laplace 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 Ω(θ)<k\Omega(\boldsymbol{\theta}) < k, build a generalized Lagrangian:

Term by term

L(θ,α;X,y)=J(θ;X,y)+α(Ω(θ)k)\mathcal{L}(\boldsymbol{\theta}, \alpha; \boldsymbol{X}, \boldsymbol{y}) = J(\boldsymbol{\theta}; \boldsymbol{X}, \boldsymbol{y}) + \alpha\,(\Omega(\boldsymbol{\theta}) - k)
α0\alpha \ge 0the KKT multiplier; it must grow whenever Ω(θ) > k and shrink whenever Ω(θ) < k, enforcing the budgetKKT multiplier
Ω(θ)k\Omega(\boldsymbol{\theta}) - kthe constraint: penalize only the amount by which the norm exceeds the budget kconstraint
α fixed\alpha^*\ \text{fixed}freeze α at its optimum and this is EXACTLY the penalized problem argmin J + α*Ω — a penalty confines w to a region, larger α ⇒ smaller regionequivalence

So weight decay confines w\boldsymbol{w} 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:

The Lᵖ constraint region: slide p from the L¹ diamond (corners on the axes → sparsity) to the L² circle to the L^∞ square
x = [0.6, 0.75]L^∞

‖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 θ\boldsymbol{\theta} back onto Ω(θ)<k\Omega(\boldsymbol{\theta})<k. Three reasons to prefer this: (1) if you know a good kk, you skip searching for the matching α\alpha; (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 XX\boldsymbol{X}^\top\boldsymbol{X}, which is singular when a direction has no variance or when there are fewer examples than features. Adding the penalty inverts XX+αI\boldsymbol{X}^\top\boldsymbol{X} + \alpha\boldsymbol{I} instead — always invertible. Likewise, logistic regression on linearly separable data has no finite optimum (if w\boldsymbol{w} separates the classes, so does 2w2\boldsymbol{w} with higher likelihood), so SGD drives w\lVert\boldsymbol{w}\rVert\to\infty until overflow; weight decay halts it. This connects to a familiar object:

Term by term

X+=limα0(XX+αI)1X\boldsymbol{X}^+ = \lim_{\alpha \searrow 0} (\boldsymbol{X}^\top\boldsymbol{X} + \alpha\boldsymbol{I})^{-1}\boldsymbol{X}^\top
(XX+αI)1X(\boldsymbol{X}^\top\boldsymbol{X} + \alpha\boldsymbol{I})^{-1}\boldsymbol{X}^\topexactly the linear-regression-with-weight-decay solution from §7.1.1 (eq 7.17)ridge solution
limα0\lim_{\alpha \searrow 0}let the regularization vanishzero-α limit
X+\boldsymbol{X}^+the Moore–Penrose pseudoinverse (§2.9) — so the pseudoinverse IS weight decay in the limit, stabilizing otherwise ill-posed problemsthe 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 x\boldsymbol{x}, so generate new (x,y)(\boldsymbol{x}, y) 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:

Label-preserving augmentation: translate / small-rotate / scale keep the 6 a 6; a 180° rotation makes it a 9 (as horizontal flips confuse b↔d)
6

Toggle transforms of the input. Label after transform:

still a “6” — label preserved ✓

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 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?

5 questions