liveBook · Manning

Overfitting

As explained in Math and Architectures of Deep Learning

A training failure mode in which a model fits idiosyncrasies of the training data too closely and generalizes poorly.

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

How Math and Architectures of Deep Learning covers it

How deep it goes
Connects capacity, decision boundaries, symptoms, regularization, and dropout, but stops short of a full optimization procedure.
Examples
Uses anomalous binary-classification points, simpler versus wriggly boundaries, and a PyTorch dropout model.
What it assumes
Assumes neural-network training, loss, and inference while grounding the distinction between memorization and abstraction.
What you can do after
Diagnose overfitting from training-test performance and apply regularization or dropout to reduce memorization.
How it connects
Ties overfitting to neural networks, decision boundaries, underfitting, regularization, L2 regularization, dropout, and Bayesian MAP estimation.

Also explained in

Compare how 24 books explain overfitting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.