Regularization

Regularization is any technique that discourages a model from fitting its training data too closely, usually by penalising complexity, so that it performs better on new data.

Regularisation, spelled regularization in American English, is the main defence against overfitting. Google's machine learning glossary defines it as any mechanism that reduces overfitting, and also as a penalty on a model's complexity. Most forms work by adding a cost for complexity to the training objective, so the model has to balance fitting the data against staying simple. A setting called the regularisation rate, usually written as lambda, controls that balance.

The two classic penalties target the size of the model's weights. L1 regularisation penalises the sum of the weights' absolute values and tends to push the weights of irrelevant features to exactly zero, removing them from the model. L2 regularisation penalises the sum of their squares, pulling large weights towards zero without eliminating them. In statistics, the L2 approach applied to regression is known as Tikhonov regularisation or ridge regression.

Neural networks added their own methods. Dropout, published in 2014 by Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever and Ruslan Salakhutdinov, randomly switches off units during training so that they cannot become too dependent on each other. In effect the network trains a huge number of thinned versions of itself, and at test time a single full network with scaled-down weights approximates their average. Early stopping, which halts training before the model starts memorising, is often counted as regularisation too. Weight decay is closely related to L2: a 2017 paper by Ilya Loshchilov and Frank Hutter showed the two are equivalent for plain gradient descent but not for adaptive optimisers like Adam, which led to AdamW.

Google's glossary flags the counterintuitive part. Increasing regularisation usually makes training loss worse, yet it tends to improve predictions on real-world data, because the aim was never to fit the training set perfectly. Too much regularisation, though, leaves the model too simple and causes underfitting.

Wikipedia makes a useful practical point: collecting more training data is usually the best cure for overfitting, and regularisation is the alternative when that is not possible.

Common questions

What is regularization in machine learning?

It is any technique that stops a model fitting its training data too closely, so it generalises better to new data. Common forms add a penalty on large weights to the training objective, randomly drop parts of the network during training, or stop training early.

What is the difference between L1 and L2 regularization?

L1 penalises the absolute size of the weights and tends to set the weights of unimportant features to exactly zero, effectively removing them. L2 penalises the squared size of the weights, shrinking large ones towards zero without removing any. L1 gives simpler, sparser models; L2 keeps all features but tames extreme weights.

What is dropout?

Dropout is a regularisation technique for neural networks that randomly switches off a share of units at each training step. This stops units relying too heavily on one another. It was set out in a 2014 paper by Srivastava, Hinton and colleagues and became one of the most widely used methods against overfitting.

Why does regularization increase training loss?

Because it deliberately stops the model fitting its training data as closely as it could. The extra error on training data is the price of a model that captures the general pattern instead of memorising quirks, which usually means better predictions on new data.

Finding more

Search for "L1 vs L2 regularization", "dropout neural networks" or "weight decay vs L2" to see how the main techniques work. Reliable sources include Google's Machine Learning Crash Course and Glossary, the original papers on arXiv and in the Journal of Machine Learning Research, and statistics textbooks.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.