Concept · Chapter 3: Machine Learning
Regularization
Regularization is anything that discourages a model from fitting the training data too closely — most commonly a penalty on large weights — so that it generalizes better.
The problem
Flexible models overfit: they bend to fit noise in the training data.
The solution
Add a penalty on model complexity to the loss (L2 'ridge' / weight decay, L1 'lasso'), or constrain training in other ways (early stopping, dropout, data augmentation).
The consequence
Complexity becomes a dial (λ) rather than a fixed choice; weight decay is used when training most large neural networks, and L1 yields sparse, interpretable models.
You should understand first
- The Turing Test
- Symbolic AI
- Logic and Rules
- Expert Systems
- Knowledge Representation
- The Knowledge-Acquisition Bottleneck
- From Rules to Learning
- Supervised, Unsupervised and Self-Supervised Learning
- Vectors
- Features, Labels and Tasks
- Loss Functions
- Derivatives and Gradients
- Gradient Descent
- Linear Regression
- Probability and Distributions
- Expected Value and Variance
- Sampling and Uncertainty
- Generalization, Overfitting and Underfitting
- Regularization
The idea
A wiggly degree-11 polynomial needs huge, finely balanced coefficients to pass through every point. Charge a price for large coefficients and the optimizer prefers a smoother curve that fits the data almost as well. In the Overfitting Lab, turning on even a small λ at degree 11 brings the test error back down to near the best simple model.
The family
- L2 / ridge / weight decay — penalize squared weights. In neural networks this is usually applied as weight decay; AdamW applies it correctly for adaptive optimizers.
- L1 / lasso — penalize absolute weights; produces sparse models where many features get weight exactly zero (built-in feature selection).
- Early stopping — stop training when validation error starts rising.
- Dropout (Chapter 4), data augmentation — make memorization harder.
What to remember
- Regularized loss = data loss + λ · complexity penalty.
- L2 (ridge / weight decay): penalize Σw²; shrinks all weights smoothly.
- L1 (lasso): penalize Σ|w|; drives many weights to exactly zero.
- λ is chosen on validation data.
- Early stopping, dropout and data augmentation are regularizers too.
Key papers
Decoupled Weight Decay Regularization
Ilya Loshchilov, Frank Hutter · 2017 · ICLR 2019
Introduced AdamW, the variant of Adam used to train most modern Transformers and LLMs.
Regression Shrinkage and Selection Via the Lasso
Robert Tibshirani · 1996 · Journal of the Royal Statistical Society, Series B
Introduced the lasso (L1 regularization), which shrinks weights and sets many exactly to zero — regularization and feature selection at once.
Watch
StatQuest with Josh Starmer
Regularization Part 1: Ridge (L2) Regression
Regularization made concrete: accept a little bias to reduce a lot of variance.