← 🧬 Biology

🧠 Neural Net

Task
Epoch 0
Loss (MSE)
Accuracy
Predictions
Neg weight Pos weight High act
Left: network diagram · Right: decision boundary (click to test a point)

About the Neural Network Backpropagation Visualiser

This simulation trains a small feed-forward network with one hidden layer, mapping two inputs to a single output (2 to N to 1). Each forward pass multiplies inputs by weights, adds a bias and applies a sigmoid activation. Backpropagation then computes the gradient of the mean squared error with respect to every weight by the chain rule, and gradient descent nudges each weight in the direction that lowers the loss, epoch after epoch.

The Task selector switches between three datasets: the classic XOR problem, a circular boundary and a two-class spiral. The Hidden neurons slider sets the layer width (2 to 16), the Learning rate slider scales the step size (0.01 to 0.20) and the Speed slider controls epochs per frame. The left panel draws the network with weights as coloured edges, while the right panel shows the live decision boundary, which you can probe by clicking any point.

Frequently Asked Questions

What does this simulation actually show?

It shows a tiny neural network learning to classify two-dimensional points in real time. On the left you see the network diagram with nodes that brighten with activation and edges coloured blue for positive weights and red for negative ones. On the right, the decision boundary morphs each epoch as training reshapes the weights.

How does backpropagation work here?

After a forward pass produces an output, the algorithm computes the error at the output, then propagates that error backwards through the layers using the chain rule of calculus. This yields the gradient of the loss with respect to each weight and bias. Gradient descent then subtracts a fraction of each gradient, scaled by the learning rate, from the corresponding weight.

Why is XOR a famous test case?

XOR is not linearly separable, so a single-layer perceptron cannot solve it. It requires at least one hidden layer to bend the decision surface. Because the simulation includes a hidden layer with a non-linear sigmoid activation, it can learn XOR, demonstrating exactly why depth and non-linearity matter in neural networks.

What do the controls do?

Task chooses the dataset (XOR, circle or spiral). Hidden neurons sets how wide the hidden layer is, from 2 to 16 units. Learning rate scales the update step from 0.01 to 0.20. Speed sets how many epochs run per animation frame. Train, Step and Reset start continuous training, advance one epoch, or reinitialise the weights respectively.

What loss function and activation does it use?

Each hidden and output neuron uses the sigmoid activation, which squashes values into the range 0 to 1. Training minimises the mean squared error between predictions and targets, reported in the panel as Loss (MSE). The output neuron always uses sigmoid so its value can be read directly as a probability-like score between 0 and 1.

How are the weights initialised?

Weights are drawn from a small random range scaled by the square root of two over the layer fan-in, a He-style initialisation that keeps early activations from saturating. Biases start at zero. Pressing Reset reinitialises all weights, which is why the same dataset can converge along a different path each time.

What does the decision boundary panel mean?

The right panel colours a grid of points by the network's output, blending towards one colour for class 0 and another for class 1. Training points are drawn on top as circles. As the network learns, the coloured regions sharpen and curve to separate the two classes. Clicking inside the panel feeds that point through the network and prints its prediction.

Is this an accurate model of real neural networks?

The mathematics is genuine: real forward propagation, real chain-rule backpropagation and real gradient descent, identical in principle to large networks. It is simplified in scale, using one small hidden layer, stochastic per-example updates and a fixed sigmoid rather than modern techniques like ReLU, mini-batches, momentum or Adam used in production systems.

What happens if I set the learning rate too high or too low?

Too high and the updates overshoot the minimum, so the loss oscillates or diverges instead of settling. Too low and training crawls, needing many more epochs to reach low error. The slider spans 0.01 to 0.20, so it is instructive to compare how the loss curve behaves at the extremes versus a moderate value.

Where is backpropagation used in the real world?

Backpropagation with gradient descent is the training engine behind almost every modern deep-learning system, including image classifiers, speech recognition, recommendation engines and large language models. The principles you watch here, scaled up to billions of weights and richer architectures, are what allow those systems to learn patterns directly from data.

🧠 Neural Network — Backpropagation

A two-layer neural network trains live on XOR, circle or spiral classification boundaries. Watch weights change as edges, activations glow as nodes, and the decision boundary evolves in real time.

🔬 What It Demonstrates

Forward pass computes activations through layers. Backpropagation computes gradients of the loss with respect to each weight. Gradient descent updates weights to reduce error.

🎮 How to Use

Pick a dataset (XOR, circle, spiral). Watch training progress — the decision surface morphs to classify points correctly. Adjust learning rate and hidden neurons.

💡 Did You Know?

Backpropagation was popularised by Rumelhart, Hinton and Williams in 1986, but the core idea (reverse-mode automatic differentiation) dates to Seppo Linnainmaa's 1970 master's thesis.