Training in motion

AI from scratch · 9 of a series

Training in motion: lesson transcript

1. Two spirals

Two hundred points, two arms, wound around each other. A hard problem: no straight cut, no gentle curve, comes close. Everything from the earlier explainers is about to run at once on this: a network of bends, a loss, gradient descent, backpropagation, and a held-out set.

2. Step zero

Before training, the weights are random and so is the boundary: a meaningless smear that gets about half the points right. This is where every network starts. The only thing it has going for it is a slope to follow.

3. Watch it learn

The scrub bar is now the clock. Every step: forward pass, loss, backpropagation, one nudge to every weight. Early on the boundary finds the easy middle; then it discovers the arms and winds itself around them. On the right, the loss falling as it goes.

4. Turn the learning rate

Same network, same data, different step size. Small and the boundary is still a smear when time runs out; large and it snaps into place in a few hundred steps, or thrashes. Each setting retrains the network from scratch, so give it a moment.

5. Turn the width

Now change how many bends the network has. Four hidden units per layer struggle to follow the arms; sixteen have folds to spare and get there sooner. More width is more capacity, which cuts both ways, as the next scene shows.

6. The held-out points

Sixty points were kept back, drawn hollow. The network never saw them. Their accuracy climbs with the training accuracy and then stalls a little below it: the gap is the model fitting the quirks of its training points. That gap, not the training score, is what you watch.

7. Name it: a training run

One *training run*: a model, a loss, an optimiser, some data, and a clock. The pieces are the ones you already have. What changes at scale is only the size of each: billions of weights, trillions of points, weeks instead of seconds. The loop is the same loop.

8. Did it land?

The two curves from the held-out scene, later in a long run.

Check your understanding

Training loss is still falling, but held-out accuracy stopped improving 500 steps ago. What is the best move?

Falling training loss with flat held-out accuracy is the overfitting signature from "Train vs test": the network is now memorising its training points. Extra steps only widen the gap. Stopping early, at the point where the held-out score peaked, is the standard fix.