How to use it
The page opens with a small network (two inputs, four hidden neurons, one output) learning to separate the orange points in the middle from the blue ring around them. The coloured background is the network's answer for every spot of the plane; the black line is where it cannot decide. Change the data, the network or the learning rate, or freeze training and move a weight yourself. In Challenges training is off and you set the weights by hand.
Controls
- Mouse: move over the map to read the output at that spot. Click a neuron, a connection line or a bias square to edit it. With Draw your own, click or drag on the map to add points.
- Touch: tap a neuron to list its bias and incoming weights, then drag a slider or type a value.
- Keyboard: Space plays or pauses, S trains one epoch, R resets, F freezes training, Esc closes the editor. The Edit menu reaches every neuron without a pointer.
- Editor: slider, number field, −0.1, +0.1, Set 0, Flip sign, and Knock out, which switches a hidden neuron off.
How it works
A neuron multiplies each input by a weight, adds a bias and passes the sum through an activation function:
a = f(w₁·x + w₂·y + b)
Here x and y are the coordinates of a point, w₁ and w₂ are the weights, b is the bias and f is tanh, ReLU or sigmoid. The sum w₁x + w₂y + b is zero exactly on a straight line, positive on one side and negative on the other. That is why a single neuron can only cut the plane with one straight line: the weights turn the line and the bias slides it.
In a hidden layer every neuron draws its own line. The next layer adds those answers up with its own weights, so half-planes combine into corners, bands and closed shapes. The small map inside each neuron shows what it has learnt. XOR is the classic case: its classes sit on opposite corners, no single line separates them, so at least one hidden layer is needed.
The output neuron uses the sigmoid σ(z) = 1 / (1 + e−z), which gives a number p between 0 and 1: how sure the network is that a point is orange. The loss measures how wrong it is. This page uses cross-entropy, averaged over the points:
L = −[ t·ln p + (1 − t)·ln(1 − p) ]
where t is 1 for an orange point and 0 for a blue one. Being confidently wrong costs a lot; being confidently right costs almost nothing.
Training is gradient descent. For each weight the network works out ∂L/∂w, how much the loss would change if that weight grew a little, and then steps the other way:
w ← w − η·∂L/∂w
η (eta) is the learning rate, the size of the step. Backpropagation gets all these derivatives in one backward sweep: the error at the output, p − t, is passed back through the weights layer by layer using the chain rule. The points are shuffled and used in small batches; one pass over all training points is an epoch. Momentum keeps a share of the previous step; L2 regularisation adds λ·w to each gradient, pulling weights towards zero.
With a learning rate that is too low the loss barely moves. Too high, and every step overshoots: the loss jumps around or explodes, and the page stops and tells you.
The hollow test points are never used for training. If the training loss keeps falling while the test loss rises, the network is memorising noise instead of the pattern. That is overfitting.
The demo is deliberately small and uses plain mini-batch gradient descent. Large networks add refinements, but the maths is the same.
Things to try
- One neuron is enough. Choose Two blobs and remove the hidden layer: a single line separates the classes almost at once.
- XOR needs a hidden layer. With zero hidden layers XOR stays near 50% however long you train. Add one layer of four neurons and it is solved.
- The right input beats a bigger network. On Circle, remove the hidden layer and switch on x² and y². One neuron now draws a circle.
- Spiral. A 2–4–1 network cannot follow the arms. Press Use the suggested network and watch the neuron maps add up to a spiral.
- Break the learning rate. Set it to 10 and press Reset, then try 0.0001. Compare the loss curves.
- Overfit on purpose. On Circle use noise 50, 40 points and four layers of eight neurons. Training accuracy reaches 100% while the test loss climbs. Then set L2 to 0.01.
- Knock out a neuron after training. Some barely matter, others take a whole side of the shape with them.
Frequently asked questions
Is this a real neural network?
Yes. The forward pass, backpropagation and gradient descent run in your browser with the same maths that larger networks use.
Why do I get a different result after Reset?
Training starts from random weights. Reset picks the next seed, so the start and the path downhill are different. Type a seed and press Re-initialise to repeat a run exactly.
Why is test accuracy lower than training accuracy?
The network only adjusts itself to the training points. Test points near the border, or noisy ones, can land on the wrong side. A large gap means overfitting.
Why can I not press Play in a challenge?
Challenges are about setting the weights yourself. Once the points are separated, Now let it learn trains the same network from random weights so you can compare. With only two hidden neurons XOR sometimes gets stuck; Reset tries another start.
Is anything sent to a server?
No. Everything runs in your browser and works offline. Settings, drawn points and solved challenges are stored only on your device.