Lesson 8.1 · 7 min read · about 50 min to master at a very slow pace
Fitting Is Not Learning
The goal of training is to predict new data well, not to match the training data. Polynomials of degree 1, 4 and 15 fitted to the same 20 noisy points show the difference.
The real goal
Training minimises the loss on the training examples, but that loss is only a proxy. What we want is good predictions on new inputs from the same distribution: generalisation. A flexible enough network can fit any training set, even one whose labels were shuffled at random, without learning anything useful.
One dataset, three models
Twenty noisy samples of (dashed). The degree-15 polynomial has the lowest error on these 20 points and the worst predictions between them. A lower training error does not mean a better model.
The rule
Whether a model generalises can only be measured on data it was not trained on. That's what validation and test sets are for (next lesson).
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 passIf the degree-15 fit passes near every point, why is it worse?
Because the points contain noise. A model flexible enough to pass through every point is also fitting the noise, which won't be there in new data. Between the training points, nothing constrains it, so it swings wildly. The degree-4 fit captures the repeatable pattern and ignores the noise.
First passWhat are risk, empirical risk, ERM and regularised ERM, in plain words?
New names for things you already do:
| Name | Meaning | You know it as |
|---|---|---|
| Risk | Average loss on all possible data | What you care about, but can't compute |
| Empirical risk | Average loss on the training data | The training cost |
| ERM | Choose the weights that minimise empirical risk | Ordinary training |
| Regularised ERM | Minimise empirical risk + a penalty | Training with L1 or L2 (lesson 9.1) |
Example: training losses 0.2, 0.4 and 0.6 give empirical risk . With an L2 penalty of , regularised ERM minimises instead.
Memory line: "Empirical risk = training loss. ERM = training. Regularised ERM = training with a penalty."
Cheatsheet
Generalisation
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.