Backprop Lab
Backprop Lab
Interactive lab · Multilayer perceptron on MNIST

Watch the error flow backwards

A small perceptron reads a handwritten digit, scores its guess with cross-entropy loss, and then sends that error back through every weight it used. Step through the ten stages of a single training update, train it on 4,000 real MNIST digits, then test it on your own handwriting.

784 pixels→16 ReLU units→10 softmax outputs12,730 trainable parametersloss in nats
Part 1

One digit, one forward pass, one backward pass

Use the stage buttons or Play full cycle. Stages 1–5 run forward (blue): pixels become a prediction and a loss. Stages 6–10 run backward (amber): the chain rule turns the loss into a gradient for every weight, layer by layer, starting at the output. Click any hidden unit to follow it in the ledger.

Sample
True label
Prediction
Loss
Load a training digit

Updates applied on this bench: 0

Part 2

Thousands of backward passes

Training repeats Part 1 over mini-batches: run the forward and backward pass on each digit in the batch, average their gradients, and take one step of size η. The loss is measured on 800 held-out test digits the network never trains on. Watch the 16 weight images turn from noise into stroke detectors.

Test accuracy
Test loss
Digits seen
Epoch
━ training loss (smoothed)━● test loss┄ random guessing, ln 10
W¹ rows: what each hidden unit looks for

Blue pixels push the unit on, vermilion pixels push it off.

Gradient size per layer (latest batch)
‖∇W²‖
‖∇W¹‖
Test accuracy by digit
Part 3

Test it on your own handwriting

Draw a digit. It is cropped, scaled into a 20×20 box, and centered by mass on a 28×28 grid, the same preprocessing MNIST uses. If the network gets it wrong, send your drawing to the Part 1 bench with its correct label and watch one backward pass fix it a little.

Draw large, centered strokes.
Network input
Prediction–
Confidence–
Correct label, then send it to the bench