Summary
Regularization changes fitting to improve generalization under stated assumptions. A validation error alone does not identify overfitting. Compare unregularized training and validation losses in evaluation mode, with matched metrics and preprocessing. Check leakage, split shift, label conventions, and optimization before selecting a constraint.
Task: fit independent coordinates with , where . Choose between small coefficients and exact zeros at penalty strength . These are analytic fixtures, not measured generalization gains.
A train/validation gap is evidence to investigate, not a diagnosis by itself
Reference drawing
L1 can erase a coefficient; L2 shrinks both toward zero
Derivation
The classical lineup
For this unit-curvature quadratic, the penalty determines the optimum:
| Added penalty | Optimum | At |
|---|---|---|
The first L1 coordinate is zero because satisfies its subgradient condition. For L2, differentiating gives , retaining both nonzero coordinates. Exact L1 zeros require an objective optimum or an appropriate nonsmooth solver, not merely a few ordinary gradient steps.
When to use what
New task: retain the weak feature by reducing L1 strength to . Move the threshold inward without changing the data quadratic. Check: ; neither coordinate is zero. Use when: held-out evidence and the desired feature count favor retaining it.
New task: select a checkpoint from epoch losses on validation. Save epoch two; patience controls stopping time, not returned weights. Check: restore loss , not the final epoch’s . Use when: further fitting worsens a trustworthy held-out objective; never select on the test set.
Failure: flipped validation label conventions can create a gap that weight decay cannot repair.
Reconstruct: combine L1 strength with L2 strength in this fixture. What is the optimum?
Answer
Threshold to , then divide by , giving . This Elastic Net formula depends on the separable unit-curvature quadratic.
L2 regularization (weight decay)
Use for a loss penalty. Its Gaussian MAP-prior interpretation depends on likelihood scaling. Decoupled decay is not generally the same optimizer update.
L1 regularization
The absolute-value penalty corresponds to independent Laplace priors under matching MAP assumptions. Feature scaling and solver choice affect sparse solutions.
L1 + L2 (Elastic Net)
Combining penalties changes both threshold and shrinkage, as the reconstruction example shows.
Dropout
Follow the mask-expectation calculation rather than treating nonlinear inference as exact ensemble averaging. Placement and probability are architecture-specific. Monte Carlo dropout deliberately retains sampling for a separate uncertainty procedure.
Early stopping
Finite optimization time changes the learned solution. Equivalence to an L2 penalty holds only under particular model, optimization, and spectral assumptions.
Data augmentation
Specify an assumed label-preserving transformation; flipping an image or replacing a word can instead change the target. Augmented samples are not additional independent observations.
The modern view: implicit regularization
Optimizer, initialization, sampling, and architecture can bias solutions without an explicit penalty. Small-batch or flat-minimum generalization advantages are conditional findings, not universal guarantees or optimizer rankings.
Common confusions
More regularization can worsen fitting and generalization. Joint changes obscure which hypothesis the experiment tested.
Why interviewers ask
Explain the evidence, selected constraint, validation decision, and a counterexample to the diagnosis.
Related: Why does dropout work?, Adam, AdamW, and modern optimizer choices.