Brain Painter
My job: paint the board so every red dot sits on red and every blue dot sits on blue. Tap the board to add dots!
The board — tap to add dots
The brain inside
Each little square shows what one neuron "sees". Lines are knobs: blue = plus, orange = minus, thick = strong.
Snapshots while learning — tap to time-travel
How it works
Every spot is a question
For each spot on the board the brain asks: "red or blue here?" It looks at just two numbers: left-right and up-down.
Neurons team up
One neuron can only draw one straight line. Many neurons each draw a line, and the next layer mixes them into curvy shapes.
Count the oopsies
Dots sitting on the wrong color make the oops-meter go up. The brain wants it as low as possible.
Nudge every knob
Each round it figures out which way to turn every single knob to shrink the oopsies — then turns each one a tiny bit.
What just happened?
- The brain painted the board red or blue, and counted the dots sitting on the wrong color.
- Every round it nudged all of its knobs a tiny bit to make fewer oopsies.
- With no thinking neurons it could only draw one straight line — not enough for a circle.
- With more neurons, each one drew its own line, and together they bent into curves that fit the dots.
For grown-ups: what's really going on
A real multi-layer perceptron (MLP) is training live in your browser, written from scratch in plain JavaScript — no libraries.
- Architecture: 2 inputs
(x, y) ∈ [−1, 1]²→Lhidden layers ofNtanh units → 1 sigmoid output = P(blue). With 0 hidden layers this is plain logistic regression, whose decision boundary is always a straight line — so it cannot separate the circle or XOR data. - Loss: binary cross-entropy
−[y·log p + (1−y)·log(1−p)], averaged over all dots (the "oops-meter"). - Training: backpropagation computes the gradient of the loss w.r.t. every weight via the chain rule; mini-batch stochastic gradient descent (batch size 10, shuffled each epoch) updates
w ← w − η·∂L/∂w. The step-size slider is the learning rate η — too large and the loss bounces or explodes. - Initialisation: Xavier/Glorot-style
w ~ N(0, 1/fan_in). "Forget" re-randomises the weights, so you can see that different starting points find different solutions. - Neuron thumbnails: each hidden unit's activation evaluated over the whole input plane — early layers draw straight lines (tanh of a linear function), deeper layers combine them into curves. This is the key idea behind representation learning.
- Inspired by TensorFlow Playground. For more visual explainers see Polo Club (e.g. CNN Explainer).