Lesson 8.3 · 8 min read · about 55 min to master at a very slow pace
Underfitting, Overfitting and Learning Curves
How to tell underfitting from overfitting with training and validation errors, how to read learning curves, and the bias–variance decomposition that explains both.
Diagnosing from the two errors
| Training error | Validation error | Diagnosis |
|---|---|---|
| High | High | Underfitting: too little capacity, or not trained enough |
| Low | Much higher | Overfitting: the gap measures it |
| Low | Low, close to training | Good fit |
Training error alone never tells you: it keeps falling as capacity grows.
Learning curves
The epoch with the lowest validation cost is where to stop: early stopping (Section 9).
Bias–variance decomposition
Model the target as with noise variance . For a model trained on a random training set:
- Bias: systematic error of the model class. Low capacity (degree 1) has high bias: underfitting.
- Variance: how much the fitted model changes with the training sample. High capacity (degree 15) has high variance: overfitting.
- Noise: irreducible; no model can remove it.
More capacity trades bias for variance. Regularisation lowers variance at the cost of a little bias.
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
First passWhy does the validation cost go up again if the network is still improving on training data?
Early in training the network learns the general pattern, which helps both sets. Later it starts fitting quirks and noise specific to the training examples. That keeps lowering the training cost but makes predictions on new data worse, so validation cost rises.
First passWhat is the difference between convergence and overfitting?
Convergence is about the optimiser: the training loss has stopped going down. Overfitting is about generalisation: the training loss keeps falling while the validation loss rises. They can happen together or apart. A network can overfit long before training converges, which is why you watch validation loss and stop early, and it can converge without overfitting if the model and data suit each other.
First passWhen do I check for bias and variance, and how?
After every training run, by comparing training loss with validation loss, before you ever touch the test set.
| Training loss | Gap (validation − training) | Problem | Fix |
|---|---|---|---|
| High | Small | High bias (underfitting) | Bigger model, train longer, lower |
| Low | Large | High variance (overfitting) | The fixes in the next doubt |
| Low | Small | Good fit | Stop and test |
The trade-off appears when you fix things: a bigger model lowers bias but raises variance, and more regularisation does the opposite. Keep whichever setting gives the lowest validation loss.
Thumb rule: "Training loss shows bias. The gap shows variance."
First passWhat can I do to stop overfitting?
Every fix falls into one of three groups:
| Group | Method | How it helps | Lesson |
|---|---|---|---|
| 1. More or better data | More data | Harder to memorise many examples | 8.1 |
| Data augmentation | "New" examples made by flipping, cropping or adding noise | 9.4 | |
| 2. Limit the model | Smaller model | Fewer neurons, less room to memorise noise | 11.1 |
| L1 / L2 | A penalty on big weights keeps the function smooth | 9.1 | |
| Dropout | Randomly switching off neurons stops co-adaptation | 9.3 | |
| 3. Limit the training | Early stopping | Stop when validation loss rises; keep the best epoch | 9.2 |
All of them lower variance at the cost of a little bias, and their settings (, , size, patience) are chosen on the validation set. Too much of any of them causes underfitting.
Memory line: "Feed it more, restrict the model, or stop it early."
Cheatsheet
Diagnose
Bias–variance
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.