A grid of neurons that learns to lay itself out
A Self-Organising Map (SOM), introduced by Teuvo Kohonen in 1982, is an unsupervised neural network that learns to arrange itself so that nearby neurons on a fixed 2D grid respond to similar inputs. The simulation on this page uses a 24×24 grid, 576 neurons, each holding a 3-vector that starts as random noise and is trained on streams of RGB colours; watch it long enough and the grid organises itself into a smooth, continuous colour map with reds, blues and greens occupying coherent neighbouring regions, despite never being told what a colour wheel looks like.
Competitive learning: one neuron wins, its neighbours learn too
Training is a loop of three steps, repeated for every input vector. First, find the Best Matching Unit (BMU): the neuron whose weight vector is closest to the current input in Euclidean distance. Second, update the BMU's weights to move slightly toward the input. Third — the step that makes it a map and not just competitive clustering — update the BMU's neighbours on the grid too, by an amount that falls off with grid distance.
for each input x:
BMU = argmin_i || w_i − x ||
for each neuron i:
θ(i, BMU, t) = exp( − dist_grid(i, BMU)² / (2 · σ(t)²) )
w_i += α(t) · θ(i, BMU, t) · (x − w_i)
σ(t) neighbourhood radius, decays exponentially from ~half the grid to ~1
α(t) learning rate, decays exponentially from ~0.5 toward 0
Early in training σ is large, so a single BMU drags a huge swath of the grid toward roughly the same colour, which is what forces neighbouring neurons to end up representing similar inputs — the topology-preserving property that gives the method its name. As σ shrinks the updates become increasingly local, letting the map refine fine detail without undoing the coarse global order it already established.
Why the schedule, not just the rule, determines the outcome
Kohonen's algorithm reliably converges to an ordered map only if the neighbourhood radius starts large enough to touch most of the grid and shrinks slowly enough that order has time to form before the updates become too local to fix a tangled arrangement. Start σ too small, or shrink it too fast, and the map gets stuck topologically twisted — a visible defect where the colour gradient folds back on itself instead of running smoothly across the grid, a failure mode you can trigger in the simulation by watching what happens on a poorly-scheduled run.
What the ordered grid is actually good for
Because SOM training only ever needs distances and no labels, it is a genuinely unsupervised technique, and because the output grid preserves neighbourhood relationships from the (often much higher-dimensional) input space, an SOM doubles as a nonlinear dimensionality reduction tool: project each real input onto its BMU's grid coordinates and points that were close in the original space end up close on the 2D map, letting you visualise structure in data no human could otherwise plot. This is why SOMs have been used for everything from organising documents by topic to visualising the state space of a chess engine.
Frequently asked questions
What makes a Self-Organising Map different from ordinary k-means clustering?
K-means assigns each point to the nearest of k independent centroids with no relationship between them. An SOM's neurons sit on a fixed grid, and training updates a BMU's grid neighbours as well as the BMU itself, which forces nearby neurons to end up representing similar inputs — a topological ordering k-means has no mechanism to produce.
Why does the neighbourhood radius need to shrink during training?
A large radius early on lets the map establish coarse global order quickly, since one strong update pulls a wide region of the grid together. Shrinking it later lets the map fill in fine local detail without those broad updates undoing the order that's already formed.
What happens if the learning rate or neighbourhood shrinks too fast?
The map can get stuck in a topologically twisted state, where the arrangement of colours (or whatever input it's mapping) folds back on itself instead of varying smoothly across the grid, because the neurons never had enough time under a wide neighbourhood to sort out a consistent global order before the updates became too local to fix it.
Try it live
Everything above runs in your browser — open Self-Organising Map and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Self-Organising Map simulation