The idea: a grid of neurons that is stretched over the data
A self-organizing map (SOM, or Kohonen map, after Teuvo Kohonen) learns without labels. It has a fixed grid of neurons; here 5 × 5 = 25. Each neuron has a weight vector w, which is a point in the same space as the data. For each sample, the neuron with the nearest weight vector wins, and it and its grid neighbours move toward the sample. Over many samples the grid spreads over the data like a net, and neurons that are close on the grid end up close in the data.
The page has 36 points in a square. The coloured dots are the 25 weight vectors; one colour per grid column, and the grey lines join grid neighbours. The panel on the right is the grid itself, which never moves.
Step 1: the best matching unit
Take one sample x. Measure the distance from x to every weight vector. The nearest neuron is the best matching unit (BMU). This is the same rule as the assignment step of K-Means, for one point. In Demo 1 the first sample is x = (6.88, 7.92); the BMU is neuron (2, 1) at distance 2.54.
Step 2: the neighbourhood is measured on the grid
Every neuron gets a share h of the pull, from its distance d to the BMU on the grid: h = exp(−d² / 2σ²). The BMU has h = 1. With radius σ = 2.5 a grid neighbour gets 0.92 and a neuron two cells away 0.73, so at the start almost the whole grid moves together. With σ = 0.3 a neighbour gets 0.004: only the winner learns.
Step 3: everyone moves toward the sample
Each weight vector moves part of the way to x: w ← w + α·h·(x − w). The learning rate α says how far; α = 0.5 means the BMU goes half way. Because grid neighbours are dragged along, neurons that are next to each other on the grid stay next to each other in the data. That is the "map" part: the grid's order is kept, which is called topology preservation.
Shrinking α and σ
Training runs 10 epochs; each one shows all 36 points once in a new shuffled order, so there are 360 updates (t = 0 … 359). Both α and σ fall in a straight line with t:
| t | 0 | 90 | 180 | 270 | 359 |
|---|---|---|---|---|---|
| learning rate α | 0.500 | 0.380 | 0.260 | 0.140 | 0.021 |
| radius σ (start 2.5) | 2.50 | 1.95 | 1.40 | 0.85 | 0.31 |
Early on, a wide radius and a big step put the grid in the right order: the ordering phase. Later, a small radius and a small step let each neuron settle near its own patch of data: the fine-tuning phase.
Two ways to measure a map
| Measure | What it counts | Good value |
|---|---|---|
| quantization error (QE) | mean distance from a sample to its BMU | small: the neurons sit near the data |
| topographic error (TE) | share of samples whose nearest and second-nearest neurons are not grid neighbours | near 0: the grid's order matches the data |
In Demo 2 QE falls from 2.042 to 0.749 and TE from 0.972 to 0.028. The page also counts folded cells: grid squares that are flipped compared with the rest of the net (0 of 16 here).
QE alone can fool you. In Demo 3 σ stays at 0.3, so only the BMU learns. That is online K-Means (competitive learning): QE ends at 0.740, even lower than Demo 2, but TE is 1.000. Every sample's two nearest neurons are far apart on the grid, so the grid tells you nothing.
A twist can freeze in
The order is set early, while σ is wide. In Demo 4 the grid starts flat but twisted: rows 0 and 1 run right to left. With σ starting at 1.0, the pull never reaches far enough to swing those rows around, and as σ shrinks the fold is locked in: 7 of 16 cells stay folded, TE = 0.139. Demo 5 starts from the same twist with σ = 2.5: the early updates move half the grid at once and the fold irons out (0 folded cells, TE = 0.028).
Neurons in a gap
In Demo 6 the points form two bands with an empty gap in the middle. The grid still has to be one connected net, so the middle column (yellow) lies in the gap. Those 5 neurons win no sample (0 hits in the grid panel), 6 neurons in all. Their weights sit between the bands because neighbours on both sides pull on them. A large weight distance between grid neighbours marks a cluster border; drawn for every pair, that is the U-matrix, the usual way to read clusters off a trained SOM.
SOM, K-Means and neural networks
| SOM | K-Means | Perceptron / MLP | |
|---|---|---|---|
| labels | none | none | needed |
| who learns per sample | BMU and its grid neighbours | one centroid (batch mean) | every weight, from the error |
| output | an ordered grid of prototypes | K unordered centroids | a class or a value |
The SOM's "neurons" are prototypes, not the weighted-sum units of a perceptron or a neural network: there is no activation function and no backpropagation. Its grid is a way to look at data in a low-dimensional picture, like PCA and t-SNE, but the result is a set of prototypes on a grid instead of one position per point. To judge plain clusters with real data points as centres, see K-Medoids and the silhouette.
See also Hopfield Network, another unsupervised network, which stores whole pictures in its weights with the Hebbian rule and recalls them from noise.
What the page leaves out
The data here is 2-D, so the grid can be drawn over it. Real SOMs map 10 to 1000 features onto the grid, and the grid (often hexagonal, often 10 × 10 or bigger) is then drawn alone, coloured by U-matrix distances or by one feature per picture. The page uses a square grid, a Gaussian neighbourhood with linear decay, and online updates; the batch SOM, other decay schedules, initializing along the first two principal components, growing SOMs and the U-matrix picture itself are only described.