Clever Quest Lab ← Labs

Neural Network Playground

Watch a small neural network learn to tell blue points from orange ones, then grab any weight and change it by hand.

Epoch0
Losstrain 0test 0
Accuracytrain 0%test 0%

Filled = training points, hollow = test points, black line = output 0.5. Point at the map to read the output there.

Data

Click or tap a neuron, a connection line or a bias square in the diagram to change its numbers.

── solid orange = positive weight, ┄┄ dashed blue = negative, thicker = larger. Small square = bias. Each box shows that neuron's output over the whole plane.

Data
Network

Inputs fed to the network

The same seed always gives the same starting weights.

Training

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

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

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.

More free games and simulators