Overfitting occurs when a neural network uses its expressive power to memorize training instances, including anomalous details, instead of learning abstractions that generalize. It therefore achieves low loss or high accuracy on training data but performs poorly on test data or real-world inference. section 9.3 section 9.4
Figure 9.11 Overfitting: data points for a binary classifier. Points belonging to different classes are visually demarcated as squares and circles. Filled squares/circles indicate training data, and unfilled squares/circles indicate test data. There are some anomalous training data instances (filled circles in the square zone). The estimated decision boundary (solid line) has become wriggly to accommodate them, which is causing many test points (unfilled squares/circles) to be misclassified. The wiggly solid curve is an example of an overfitted decision boundary. If we had chosen a “simpler” decision boundary (dashed straight line), the two anomalous training points would have been misclassified, but the machine would have performed much better in tests.
Compare a wriggly decision boundary that accommodates anomalous training points with a simpler boundary that sacrifices a few training examples but classifies test points better. section 9.3
Recognize overfitting through these patterns:
- The model has more expressive power—such as too many perceptrons or weights—relative to the number of training instances. section 9.3
- The learned decision boundary follows every nook, bend, and kink of the training data, including noise or anomalous points. section 9.3
- Training performance is excellent while testing or real-life inference performance is poor; underfitting instead harms both training and testing performance. section 9.3 section 9.4
Regularization addresses overfitting by favoring simpler solutions. Adding a penalty such as the L2 norm of the weights discourages large parameters; dropout instead randomly turns off neurons during training, reducing reliance on a small group and mitigating co-adaptation. section 9.3.6 section 9.4
Dropout in PyTorch
A model can insert torch.nn.Dropout(p=0.2) between linear layers. During training, neurons are randomly disabled; during inference, dropout is turned off. The resulting pressure to distribute weights across neurons helps prevent memorization. section 9.3.6























