Regularization
Also known as: regularisation
Any rule added during learning that holds a model back from fitting its examples too closely, so it does better on new cases.
Draft - this entry has not been reviewed yet.
Formal
A change to model training that trades a little closeness of fit on the training data for better results on unseen data, most often by adding a penalty for large model weights to the loss function, or by switching off random parts of a neural network while it learns.
In plain English
Like a word limit on an essay. The writer cannot pour in every detail they remember, so they keep only the points that really matter.
In practice
A hospital team's model for spotting patients at risk of coming back fits its old records perfectly but misses new cases; adding a weight penalty and tuning its strength on a validation set closes most of the gap.
Why it matters
Without it, flexible models tend to learn their examples by heart and look far better in testing than they are in real use.
Technical deep dive
Explicit penalty methods add a term to the training objective. L2 regularization adds lambda times the sum of squared weights; in linear regression this is ridge regression (Hoerl and Kennard, 1970), a special case of Tikhonov regularization, and it shrinks all coefficients smoothly toward zero. L1 regularization adds lambda times the sum of absolute weights; in linear regression this is the lasso (Tibshirani, 1996), which drives some coefficients to exactly zero and so performs feature selection. Elastic net mixes the two. In scikit-learn the strength is the alpha argument of Ridge and Lasso, and it is normally chosen by cross-validation (RidgeCV, LassoCV). From a Bayesian view, L2 corresponds to a Gaussian prior on the weights and L1 to a Laplace prior, so the penalised solution is a maximum a posteriori estimate.
Weight decay multiplies weights by a factor slightly below one at every update. For plain stochastic gradient descent this is equivalent to an L2 penalty, but Loshchilov and Hutter (2019) showed that it is not equivalent for adaptive optimisers such as Adam, where the L2 gradient is rescaled per parameter. Their decoupled version, AdamW, applies decay directly to the weights and is now the default choice for training transformers; PyTorch exposes it as torch.optim.AdamW with a weight_decay argument.
Deep learning adds implicit and structural regularisers. Dropout (Srivastava et al., 2014) randomly zeroes units during training, which approximates averaging an ensemble of thinned networks; at test time all units are used with rescaled activations. Early stopping halts training when validation loss stops improving and, for quadratic losses, behaves much like an L2 penalty. Data augmentation, label smoothing, batch normalisation noise, parameter sharing in convolutional networks, and the implicit bias of stochastic gradient descent toward flat or low-norm solutions also regularise. The strength of every regulariser is itself a hyperparameter and moves the model along the bias-variance trade-off: too little leaves overfitting, too much causes underfitting.
What to learn first
Everything this builds on, foundations first.
- Training data
- →Machine learning
- →Loss function
- →Regularization
Relationships
- Requires
- Loss function
- Mitigates
- Overfitting
Sources & further reading
Official documentation
- scikit-learn User Guide, Linear Models (Ridge, Lasso) · scikit-learn
Reference works
- Srivastava et al. (2014), Dropout, A Simple Way to Prevent Neural Networks from Overfitting · Journal of Machine Learning Research
- Loshchilov & Hutter (2019), Decoupled Weight Decay Regularization · ICLR 2019
Textbooks
Where this data comes from
This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.
See the review queueSuggest a correction on GitHubThis term as JSON
Check yourself
Loading…