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.

Not startedJump to quiz

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

-10100.51
Degree 1: too simple. Misses the pattern (underfits).
-10100.51
Degree 4: follows the pattern, ignores the noise.
-10100.51
Degree 15: chases every point, wild in between (overfits).

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:

NameMeaningYou know it as
RiskAverage loss on all possible dataWhat you care about, but can't compute
Empirical riskAverage loss on the training dataThe training cost
ERMChoose the weights that minimise empirical riskOrdinary training
Regularised ERMMinimise empirical risk + a penaltyTraining 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

Training loss is a proxy. The goal is low error on unseen data from the same distribution; measure it on held-out data.

See every cheatsheet by category →

Check your understanding

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

Q1interpretPolynomials of degree 1, 4 and 15 are fitted to 20 noisy samples of . Which has the lowest error on those 20 points?
Q2conceptWhat does "generalisation" mean for a trained network?
Q3interpretA large network reaches near-zero training error on a dataset whose labels were shuffled at random. What does this show?
Q4applyHow should you decide whether your model generalises?
Q5conceptBetween the training points, why does the degree-15 fit swing so wildly?