HomeMachine Learning & Neural NetworksSelf-Organising Map

🗺️ Self-Organising Map

Watch a Kohonen SOM organise a 24×24 neuron lattice to map RGB colour inputs. Random noise converges to a smooth, topology-preserving colour map as the neighbourhood radius and learning rate decay.

Machine Learning & Neural Networks3DModerate60 FPS
self-organising-map ↗ Open standalone

About the Self-Organising Map

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.

Frequently Asked Questions

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.

What do the Colour Input buttons do?

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.

What does the Speed slider control?

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.

What are α and σ, and why do they decay?

α 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.

Why does the map start as random noise?

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.

What does "topology-preserving" mean here?

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.

Is this an accurate self-organising map?

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.

How is a SOM different from k-means clustering?

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.

Where are self-organising maps used in practice?

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.

⚙ Under the hood

24×24 Kohonen SOM (576 neurons, 3D RGB input). Gaussian neighbourhood update as α and σ decay exponentially, across four colour input distributions.

Canvas 2DUnsupervisedTopology

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)