Watch a Neural Net Learn

Train a small network in your browser on 2D points and watch the decision boundary bend, the weights change and overfitting happen, step by step.

AI and Machine Learning
Epoch 0

The network

Each line is a connection; thicker and brighter means a stronger weight, blue or orange for its sign. Each box is a neuron, showing what it has learned to detect. Use + and โˆ’ to add or remove layers and neurons.

Loss over time

Training loss Test loss

How it works

Method

Pick a dataset (a spiral, rings, XOR, two clusters, or draw your own points) and the network trains on it live. The main view shows the points over the network's current guess as a colour field that bends as it learns. A diagram shows every weight updating and a thumbnail of what each neuron has learned to detect; a chart tracks training loss against test loss so you can watch overfitting appear. A step through mode slows one training step right down to show the error flowing backwards through the network.

Data

2D points generated in your browser (spiral, circles, XOR, two clusters), or points you paint yourself. No outside datasets. The data is split into a training set and a held out test set so overfitting can be seen.

Model

A small multilayer perceptron (up to four hidden layers of up to eight neurons) written from scratch, trained by full batch gradient descent with a choice of activation (ReLU, tanh, sigmoid), learning rate and L2 regularization. Every number on screen is the real one from the running network.

Build

Plain TypeScript: the network, the training loop and backpropagation are all handwritten, so the step through shows the real algorithm. The decision field, network diagram, neuron thumbnails and loss chart are drawn on canvases and SVG. Nothing is sent anywhere.

Tech

  • Deep learning
  • Backpropagation
  • Visualization
  • TypeScript

Data credits

No outside data: everything in this tool is simulated.