The Training Loop

How does a model actually learn? It repeats a simple loop, over and over:

  1. Predict. Run the current model on the training examples.
  2. Measure. Compare predictions to the true labels — how wrong are we? That number is the loss.
  3. Adjust. Nudge the model's knobs a little in the direction that reduces the loss.

Round and round, each pass over the data shaving a bit more error away. One full pass is called an epoch, and "training" is just running this loop until the loss stops improving.

Watch it learn

Drag the step slider to advance the training loop. The line starts flat and useless; with each step it's nudged toward the data and the loss drops. You're watching predict–measure–adjust play out — the same loop, whether the model is a single line or a giant neural network.

The same loop, all the way up

Astonishingly, this three-step loop is essentially all of model training — from this toy line to systems with billions of knobs. What changes is only how the "adjust" step is computed, and that's the engine called gradient descent, which we build next. Master the loop and you understand the heartbeat of machine learning.