FIG. 02 · Live
Neural Network Autograd Lab
A real scalar autograd engine, written in TypeScript, drives both modes. Every number on screen is computed by reverse-mode differentiation and checked against finite differences.
Inputs and parameters
FIG. 02.1- o
- —
- Loss L
- —
- Gradient check
- — —
Computational graph
FIG. 02.2Each node shows its value (top) and the gradient of the loss with respect to it (bottom).
Chain rule, step by step
FIG. 02.3Forward pass
Backward pass
Update (gradient descent)
Loss after each step
FIG. 02.4- Epoch
- 0
- Loss
- —
- Accuracy
- —
Keyboard: Space plays or pauses, S steps once, R resets.
Decision boundary
FIG. 02.5Background colour shows the network’s prediction across the plane; dots are training points.
Network
FIG. 02.6Line thickness shows weight magnitude; colour shows sign.
Loss over epochs
FIG. 02.7How it works
Methodology
- Every arithmetic operation creates a Value node that remembers its inputs and a small closure describing its local derivative.
- Calling backward() sorts the graph topologically, seeds the output gradient with 1 and walks the nodes in reverse, applying the chain rule once per edge.
- The playground trains a multilayer perceptron with full-batch gradient descent on mean squared error, with labels of +1 and −1 and a tanh output.
- A live gradient check compares every analytic gradient with a central finite difference; the unit tests require agreement within 1e−5 for every operation and every network size.
The engine follows the design of Andrej Karpathy’s micrograd (MIT licence).