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.

Not startedJump to quiz

Diagnosing from the two errors

Training errorValidation errorDiagnosis
HighHighUnderfitting: too little capacity, or not trained enough
LowMuch higherOverfitting: the gap measures it
LowLow, close to trainingGood fit

Training error alone never tells you: it keeps falling as capacity grows.

Learning curves

00.51020406080100epochcostbest epoch: stop here
training costvalidation cost
Training cost falls throughout. Validation cost reaches a minimum and then rises as the network starts fitting noise. Record both after every epoch.

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 lossGap (validation − training)ProblemFix
HighSmallHigh bias (underfitting)Bigger model, train longer, lower
LowLargeHigh variance (overfitting)The fixes in the next doubt
LowSmallGood fitStop 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:

GroupMethodHow it helpsLesson
1. More or better dataMore dataHarder to memorise many examples8.1
Data augmentation"New" examples made by flipping, cropping or adding noise9.4
2. Limit the modelSmaller modelFewer neurons, less room to memorise noise11.1
L1 / L2A penalty on big weights keeps the function smooth9.1
DropoutRandomly switching off neurons stops co-adaptation9.3
3. Limit the trainingEarly stoppingStop when validation loss rises; keep the best epoch9.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

Both errors high: underfitting. Train low, validation much higher: overfitting (the gap). Watch learning curves every epoch.

Bias–variance

. Capacity ↑: bias ↓, variance ↑.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1interpretTraining error 18%, validation error 19%, while similar models reach 5%. What's the diagnosis?
Q2interpretTraining error 1%, validation error 15%. What's the diagnosis?
Q3conceptOn a typical learning curve, what does the validation cost do as training continues?
Q4conceptIn the bias–variance decomposition, which term no model can reduce?
Q5applyA degree-15 polynomial changes drastically when refitted on a fresh sample of 20 points. Which term is large?