Watch a network learn pass or fail

Watch a forward pass and a backward pass, then see the error fall as the weights change.

Artificial intelligence Intermediate Two layers · Binary classification ~6 min
The idea

Two layers, one yes-or-no guess

This network learns a yes-or-no answer from two clues. The clues are a revision score and a practice score for Mei, Ali, Sam, and Noor. Pass and fail are the two classes. A problem with two classes is called binary classification.

Scores start in the input layer and travel along connections to one output. The weight on a connection says how strongly that clue counts. The output also has a bias, one number added at the output. A forward pass turns the clues into a guess between 0 and 1. Near 1 means pass. Near 0 means fail.

The error is the gap between a guess and the correct class. The curve shows the average gap for the four students. The network reduces that error by changing the weights, one step at a time.

TipThere is no hidden layer here, only an input layer and an output layer. A real network has many more neurons. Each step here is also large enough to see, so the weights move in clear jumps.
DataThe same four students
StudentRevisionPracticeClass
Mei0.100.20fail
Ali0.200.30fail
Sam0.800.90pass
Noor0.900.80pass

A score near 0 is low. A score near 1 is high. These four rows are used in every step.

Interactive

Run the simulation

Look at the row of guesses, then at the curve on the side. The curve moves when the weights change.

Step 0 / 0
Network and error curvetrain
Ready
Shortcuts: Space play/pause · → step · ← back · R reset
Remember

Three moves, in order

Forward, then back, then a change to the weights.

1

Forward pass

Clues move from the input layer to the output. The output makes a guess between 0 and 1.

2

Backpropagation

The error travels back along each connection. Every weight learns whether it should go up or down.

3

Gradient descent

Each update is one step that reduces the average error. The curve on the side is those steps.