Overfitting and Regularization
Briefly
Overfitting occurs when the model memorizes the training examples instead of learning general rules. Regularization is a set of techniques that prevent the model from memorizing and encourage it to find general patterns.
What is Overfitting
Imagine the model has memorized the examples rather than learning the rules. It performs nearly perfectly on the training data but fails on unseen data. This is overfitting (overfitting).
The opposite extreme is underfitting: the model is too simple to capture even obvious patterns.
Signs of Overfitting
- The error on the training data is much lower than on the validation data.
- The model excels at remembering formulations from the dataset but fails to apply knowledge to new tasks.
- As the number of parameters increases, the quality on new data starts to decrease.
Methods to Combat Overfitting
Dropout
During training, a random subset of neurons is turned off. The network cannot rely on individual neurons and is forced to distribute knowledge across the entire architecture.
Weight Decay
A penalty is added to the loss function for large weight values. The model prefers simpler solutions to complex ones.
Early Stopping
Training is stopped when the error on the validation data stops decreasing, even if it is still decreasing on the training data.
More Data
The most honest approach. If the model has enough diverse examples, it is harder for it to memorize them all — it has to generalize.
Underfitting: The Other Side
If the model cannot perform well even on the training data, it is either too simple or has not been trained enough. The remedy is to increase the model size, add features, or train longer.
