The Lab
Ported to TypeScript

A Neuron Learns

A single-layer perceptron shown four labeled examples, nudging its three weights on every pass until its guesses snap to the right answers.

Machine learningGradient descentTypeScript
Original Python experiment by GM
Loading demo…

Before transformers and billion-parameter models, this is the whole idea in miniature: a neuron is a weighted sum squashed through a sigmoid, and learning is just repeatedly nudging the weights in the direction that reduces error. The famous eleven-line version fits in a tweet.

Watch it run and you can see the abstraction that powers everything downstream. The predictions start as noise near 0.5, the error shrinks pass after pass, and the weights slide toward the values that encode the rule hiding in the data — here, that only the first input matters.

On the rebuild

Ported from a Python 2 / NumPy script (the classic single-layer example). The training loop is reimplemented in TypeScript and animated so you can watch prediction, error, and weights converge, in place of the original's static matplotlib panels.

Next in the Lab
MorphballOpen

Layered parallax depth from flat shapes and different scroll speeds.