Kohonen Self-Organising Map with a 24×24 neuron lattice learning to map 3-dimensional RGB colour inputs. Each iteration: sample a random colour from the selected distribution; find the Best Matching Unit (BMU) by minimum Euclidean distance; update the BMU and its neighbourhood with the Gaussian kernel h = exp(−d²/(2σ²)), scaled by learning rate α. Both α and σ decay exponentially over time. The map self-organises from random noise into a smooth topology-preserving colour gradient.
This simulation runs a Kohonen Self-Organising Map: a 24×24 lattice of 576 neurons, each holding a 3-dimensional RGB weight vector. On every iteration a colour is drawn from the chosen distribution, the Best Matching Unit (BMU) is found by minimum squared Euclidean distance, and the BMU and its neighbours are pulled towards the input by the rule w ← w + α·h·(x − w), where h = exp(−d²/2σ²) is a Gaussian neighbourhood kernel.
The learning rate α (starting at 0.5) and the neighbourhood radius σ (starting at 8) both decay exponentially with iteration count, so early sweeps coarsely order the whole map and later ones fine-tune local detail. The Colour Input buttons switch the sample distribution (Rainbow, Warm, Cool or Random), and the Speed slider sets how many training steps run per frame. SOMs are used for dimensionality reduction, clustering and data visualisation.
What is a self-organising map?
A self-organising map (SOM), or Kohonen map, is an unsupervised neural network that projects high-dimensional data onto a low-dimensional grid of neurons. Here a 24×24 grid of 576 neurons learns to represent 3D RGB colours, arranging similar colours next to each other so the grid preserves the topology of the input.
What is the Best Matching Unit (BMU)?
For each input colour, the BMU is the neuron whose weight vector is closest to that input by Euclidean distance. The simulation searches all 576 neurons, flashes the winner with a white outline, and reports its grid coordinates in the telemetry panel. The BMU is the centre around which the neighbourhood update is applied.
How does the map learn?
On each step it samples a colour, finds the BMU, then nudges the BMU and nearby neurons towards that colour using w ← w + α·h·(x − w). The Gaussian factor h means closer neurons move more than distant ones, so over thousands of iterations the random initial weights organise into a smooth colour gradient.
They select which distribution the training colours are drawn from. Rainbow covers the full hue circle, Warm spans reds to yellows, Cool spans cyans to violets, and Random picks uniformly random RGB values. Changing the input resets the map, because the learned layout reflects whatever distribution it was trained on.
The slider sets how many training iterations are executed per animation frame: Slow (10), Medium (50), Fast (200) or Blazing (800). Higher speeds let the map converge in fewer seconds, while slower settings let you watch individual BMU updates and the gradual smoothing of the colour field.
α is the learning rate (how strongly neurons move towards an input) and σ is the neighbourhood radius (how far the influence spreads). Both decay exponentially, here as α₀·exp(−t/4000) and σ₀·exp(−t/2500). Large early values give broad, global ordering; shrinking values refine local structure and let the map settle.
The 576 weight vectors are initialised with random RGB values, so the grid begins as colour static. As training proceeds the neighbourhood updates correlate nearby neurons, and the noise resolves into ordered patches of similar colour, demonstrating how self-organisation emerges purely from local competitive learning.
It means inputs that are similar in the original space map to neurons that are close together on the grid. After training, neighbouring cells hold near-identical colours and the whole lattice forms a continuous gradient, so the 2D grid faithfully reflects the structure of the 3D colour space.
Yes. It implements the standard Kohonen algorithm: competitive BMU selection by Euclidean distance, a Gaussian neighbourhood function, and exponentially decaying learning rate and radius. It is simplified to a 24×24 grid and 3D colour inputs for clarity, but the core update rule and decay schedule match the classic formulation.
Both place reference vectors among data, but k-means treats clusters independently, whereas a SOM imposes a fixed grid topology and updates a neuron together with its neighbours. This neighbourhood coupling makes nearby SOM units learn related values, producing an ordered map rather than a set of unrelated centroids.
SOMs are applied to data visualisation, exploratory clustering and dimensionality reduction across fields such as document and image organisation, financial and customer segmentation, fault detection and bioinformatics. The colour example here is the classic teaching demonstration because the high-dimensional ordering is directly visible as a smooth gradient.