Neural Network Playground: Train a Network in Your Browser and Watch It Learn

Free neural network playground: choose a dataset, inputs, layers, neurons and activation, then train a real network in your browser and watch the decision boundary, the loss curve and what every hidden neuron has learned. Follow one point through the maths. Private: nothing is uploaded.

Inputs the network may use:
Hidden layers2
Try this:
class 1 (orange) class 0 (blue)filled = training data, ring = test data

Orange line = loss on the training data, blue = loss on data it never trained on (test). If test stays high while training drops, it is memorising (overfitting).

The network

Each square is one neuron, drawn as the picture of inputs it responds to. Blue lines are positive weights, orange negative; thicker = stronger.

The maths for one point

Click a spot on the picture to follow that point through the network.

Train a neural network and watch it learn

A neural network is a stack of layers; each neuron adds up its inputs times weights, adds a bias, and passes the result through an activation function. Training means nudging every weight a little to make the mistakes smaller, over and over. This playground trains a real one on your computer while you watch: the coloured picture is the network's prediction at every point, the squares inside the diagram show what each hidden neuron has learned to detect, and the curve shows the loss falling.

Things to try

  • Circle with only x and y as inputs and no hidden layers: a straight line can't split a ring. Add a hidden layer, or switch on x² and y², and it becomes easy.
  • Spiral is hard: try three layers of 8 neurons, all the sine inputs, and the Adam optimiser, and give it a minute.
  • Set the learning rate to 1 and watch training become unstable; set it to 0.001 and watch it crawl.
  • Add noise, then give a big network few points and see the test loss rise while the training loss falls: overfitting. Weight decay (L2) reduces it.

Questions

What does the learning rate do?

It is the size of each nudge. Too small and learning is slow; too big and the weights overshoot and bounce around.

Why do we need activation functions?

Without them every layer is just a matrix multiplication, and a stack of matrix multiplications is still one matrix multiplication: the network could only draw straight lines. The bend in tanh or ReLU is what lets layers combine into curves.

What is the difference between the training and test data?

The network only learns from the training points (solid dots). The test points (rings) are held back to check it has learned the pattern rather than memorised the dots.

Is this a real neural network?

Yes: forward pass, backpropagation and the optimiser are real and run in your browser (a few hundred weights). It is tiny compared to the networks behind chatbots, but the mathematics is the same. Nothing is uploaded.

Comments
Advertisement