Tools

Neural Network Playground

Train a small neural network in your browser

Epoch 0Loss –Accuracy –

Tip: click the plot to add an orange point, shift-click (or long-press) for blue.

How to use the neural network playground

  1. Pick a dataset. Orange and blue dots are two classes that the network must learn to separate.
  2. Choose the network shape: how many hidden layers, how many neurons in each, the activation function and the learning rate.
  3. Press Train. The background colour shows what the network currently predicts for every point, and the loss and accuracy update as it learns.
  4. Experiment: try XOR with no hidden layer, the spiral with a small network, or a very high learning rate, and see what happens. Click the plot to add your own points.

What you are watching

This is a real multi-layer perceptron, trained from scratch in your browser with backpropagation and stochastic gradient descent. Each neuron computes a weighted sum of its inputs and passes it through an activation function; the final neuron outputs a probability between 0 and 1 for "orange". Training repeatedly nudges every weight a little in the direction that reduces the cross-entropy loss, the standard measure of how wrong a classifier's probabilities are.

The experiments reveal key ideas in deep learning. With no hidden layer the network can only draw a straight line, so it cannot solve XOR or the circle. Hidden layers let it bend the boundary, and more neurons let it fit more complicated shapes such as the spiral, but too many can make it memorise noise (overfitting). A learning rate that is too high makes the loss jump around or explode; too low and training crawls. ReLU often trains faster, while tanh gives smoother boundaries. It is inspired by Google's TensorFlow Playground and needs no installation.

Why can't the network learn XOR without hidden layers?

A single neuron draws one straight boundary, and XOR's classes cannot be separated by one line. A hidden layer combines several lines.

What is the loss?

Binary cross-entropy: it is low when the network gives high probability to the correct class and grows quickly for confident mistakes.

Why does accuracy sometimes get stuck?

The network may be too small, the learning rate too low or too high, or it is stuck in a poor local solution. Reset the weights and try again.