CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Artificial Intelligence / How a Neural Network Thinks

Project: Train Your Own

Lesson 10 of 10 · 8 min · Free, no account needed

What you will learn

  • Accuracy is the share of points a network gets right. The test set gives the honest one.
  • More hidden neurons draw more complex boundaries. The network size that's just big enough is best.
  • One epoch is one pass over the training data. The learning rate sets how big each step is.
  • The recipe: collect, label, pick a network, train, test on new data, fix.

Start the lesson

How the lesson goes

  1. Two kinds of points, twisted into a spiral. No line can split them.

    How many points can one straight line get right anyway? Drag the marker to your guess, then Check.

  2. Warm-up: one neuron, two clouds of points.

    Press Train and watch the shading: it's what the neuron believes about every spot.

  3. New data: an orange disk inside a blue ring.

    Draw where you think one neuron's line will go. Then press Train one neuron.

  4. Give it a hidden layer.

    Add hidden neurons with + and press Train. Get the ring to 95%, then Check.

  5. How to score a network, in AI words.

    Tap to reveal.

    Accuracy is the share of points the network gets right. 47 of 50 right is 94%.

    The number of hidden neurons is the network size. Bigger networks can draw more complex boundaries.

    One epoch is one pass of the training loop over all the training data: predict, measure the loss, adjust every weight.

  6. Same ring, three neurons. Now you set the learning rate.

    Pick a learning rate and press Train: you get 200 epochs. Reach 90%, then Check.

  7. Open the network. Which hidden neuron draws the right edge?

    Tap a hidden neuron: it opens as a cup and shows its own line. Find the one on the right, then Check.

  8. Project: train a network on the spiral.

    Set the neurons, the learning rate and the epochs, then Train. The score that counts is the test set: points the network never trains on.

  9. Is your network bigger than it needs to be?

    Same learning rate and epochs. Remove neurons until the test score breaks under 90%, then fix it with the smallest network that holds. Check.

  10. A bird app learns to name birds from photos. Build its recipe.

    Put the 6 stations in order: it's everything you did in this course.

  11. Training accuracy 99%, test accuracy 71%. What now?

  12. You trained a neural network. Here's your card.

    Your network from the project, with its real numbers. Tap Share to make it a picture.

Previous lesson: Why Networks Get Fooled · Part of the course: How a Neural Network Thinks

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

Loading TwiddleLab