CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Artificial Intelligence / How a Neural Network Thinks

The Learning Loop

Lesson 6 of 10 · 7 min · Free, no account needed

What you will learn

  • One training step is predict, measure, adjust, always in that order.
  • The training loop repeats the step, so nobody has to press a button a million times.
  • One pass over all the training data is an epoch.
  • A loop can stop by itself when the error is small enough, and the same loop trains on any data.

Start the lesson

How the lesson goes

  1. Press Step until the ball reaches the bottom.

    This time each step is tiny, like in real training. Keep pressing.

  2. Build one whole training step from three blocks.

    Put predict, measure and adjust in the order that works, press Run, then Check.

  3. Now wrap the step in a loop: repeat N times.

    Turn N and press Run. Find the smallest N that gets the ball to the bottom, then Check.

  4. This loop runs inside every neural network.

    Tap to reveal.

    Predict, measure, adjust, repeat: this is the training loop.

    Each trip around it is one training step. Adjust is gradient descent from the last lesson.

    Real data has many examples. One pass over all of them is an epoch. Training often runs many epochs.

  5. Run it slowly. Before each repeat, call where the ball lands.

    Press Run. The loop pauses before every repeat: tap one of the dashed spots.

  6. Someone's loop sends the ball uphill. Fix it.

    Press Run to see the bug. Tap the block that's wrong to fix it, Run again, then Check.

  7. Loop golf: make the loop stop by itself at the bottom.

    Par is 4 blocks. A loop that stops itself beats one where you guess the count. Run, then Check.

  8. You run this loop yourself: learning free throws.

    Put the cards in the predict, measure and adjust slots. One card doesn't belong. Run, then Check.

  9. Where does this loop leave m?

    Slide the marker to the final m, then Check.

  10. Your loop, on new data.

    Here's the loop you built in the golf game. Tap a new problem and let it train.

Previous lesson: Rolling Down the Loss · Next lesson: A Neuron Is a Weighted Vote · Part of the course: How a Neural Network Thinks

Lessons are interactive and need JavaScript. Turn it on to play them.

Loading TwiddleLab