Machine Learning 101 · Interactive

How a Neural Network Learns

Watch a tiny brain teach itself XOR — one of the simplest problems a computer can't solve with a straight line. Press Train and see the connections strengthen, the loss fall, and the answers snap into place.

The Network

2 inputs → 2 hidden neurons → 1 output. Each line is a weight: thick & green means “pass this signal through,” thin & red means “block it.”

Positive weight (+) Negative weight (−) Strength = thickness
0.50
Bigger = learns faster but can overshoot. Too small = crawls. Try cranking it to see the loss explode.
Epoch
0
Loss (error)
Accuracy
0%

Loss over time

Loss is how wrong the network is. The goal of learning is to push this curve toward the floor.

The XOR task

Output is 1 only when exactly one input is 1. Watch the network's guess converge on the truth.

In 1In 2TargetNetwork's guess
1

Forward pass

Each neuron mixes its inputs using its weights, then squashes the result with a curve (the tanh function). Numbers flow left → right to produce a guess.

2

Measure the error

We compare the guess to the target. The gap is the loss. A big loss means the network is badly wrong; zero means perfect.

3

Backpropagate & adjust

The network works backward, nudging every weight a tiny bit to reduce the error. Repeat thousands of times and the weights settle into a solution.