Watch a neural network learn

This network is training in your browser right now, on gradlab: an engine written from scratch in plain JavaScript, with no libraries. The coloured background is what the network currently believes. The dots are the data it is learning from.

Set it up

Try zero hidden layers on Spirals: a network with no hidden layer can only draw straight lines.

How it is doing

0training steps
0loss
0%accuracy, seen data
0%accuracy, unseen data
loss, seen dataloss, unseen datalog scale

A quarter of the points are held back (drawn hollow) and never used for training, to show whether the network has learned the pattern or only memorised the dots.

1. Guess

The points go through the network: each layer multiplies by its weights, adds a bias, and bends the result with the activation.

2. Measure

The loss is one number saying how wrong the guesses are. Lower is better.

3. Trace back

The engine replays the calculation in reverse to find how much each weight contributed to the error. This is backpropagation.

4. Nudge

The optimiser moves every weight slightly in the direction that reduces the loss. Repeat a few hundred times.

Draw a digit and have an AI read it →
Watch a tiny language model write →
Watch an AI learn to balance a pole →
See what a machine thinks words mean →
Watch an AI draw its own digits →