A 2D Kohonen self-organising map: a square grid of neurons, each holding a 2D weight vector, starts scattered at random positions. On every training step a point is sampled from the chosen input distribution, the Best Matching Unit (BMU) is found by minimum Euclidean distance among all neurons, and the BMU and its grid neighbours are pulled toward the sample with a Gaussian neighbourhood kernel scaled by a learning rate. Both the learning rate and the neighbourhood radius decay over time, so the tangled grid gradually unfolds into a smooth net that traces the shape of the input data.

Input sample Grid connection Best matching unit

About the 2D Self-Organising Map

Written by MySimulator Team · Reviewed by MySimulator Editorial Review

Last updated: 13 September 2026

This is a 2D-canvas companion to the 3D colour Self-Organising Map simulation. Instead of mapping 3D RGB colours onto a grid, this version trains a Kohonen map directly against a 2D input distribution, so the effect that gives SOMs their name — a grid net unfolding to trace the shape of the data — is directly visible as motion rather than as colour blending.

Every neuron in the N×N lattice holds its own 2D weight vector (x, y). On each iteration a point is drawn from the selected distribution (a filled square, a ring, two Gaussian clusters, or a spiral), the Best Matching Unit is found by minimum Euclidean distance across all neurons, and the BMU and its grid neighbours are nudged toward the sample using the Gaussian neighbourhood rule w ← w + α·h·(x − w), where h = exp(−d²/2σ²) and d is measured in grid steps, not screen pixels. Both the learning rate α and the neighbourhood radius σ decay exponentially with iteration count, so early training reorders the whole grid coarsely while later training refines local detail — visually, the tangled starting net progressively straightens and stretches until it lies flat across the input shape.

Frequently Asked Questions

How is this different from the 3D Self-Organising Map?

The training algorithm is identical — BMU search by Euclidean distance, Gaussian neighbourhood update, exponentially decaying learning rate and radius. The 3D version's neurons hold 3D RGB weight vectors and are rendered as colour swatches; this version's neurons hold 2D (x, y) weight vectors and are rendered as points connected by grid edges, so the unfolding of the lattice over the input shape is visible directly as movement instead of as a colour gradient.

What is the Best Matching Unit (BMU)?

For every sampled point, the BMU is whichever neuron's 2D weight vector is closest to that point by Euclidean distance. The simulation checks all neurons every step, flashes the winner white, and centres the neighbourhood update on its grid position.

Why does the grid start tangled?

Every neuron's weight vector is initialised to a random position inside the canvas, so the grid lines connecting neighbouring neurons cross each other chaotically at the start. As training proceeds, neighbouring neurons are repeatedly pulled toward the same nearby samples, which correlates their positions and untangles the mesh into an ordered net.

What do the Input Distribution options do?

They choose the shape the map has to learn: Uniform Square fills the canvas evenly, Ring samples an annulus, Two Clusters draws from two separated Gaussian blobs, and Spiral samples along an Archimedean spiral. Changing the distribution resets training, since the target shape is different.

What does the Grid Size slider control?

It sets N in the N×N neuron lattice, from 6×6 (36 neurons) to 20×20 (400 neurons). A larger grid can trace finer detail in the input shape but needs more iterations to fully unfold; the neighbourhood radius σ is re-scaled to the grid size whenever it changes.

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

α is the learning rate controlling how strongly a neuron moves toward a sample, and σ is the neighbourhood radius controlling how many grid neighbours move with the BMU. Both start high so the whole grid reorganises quickly and coarsely, then decay exponentially so later updates only fine-tune local structure and the map settles into a stable shape.

What is the mean quantisation error?

It is the running average distance between each recent input sample and its BMU. A large value means the grid still poorly represents the data; as training converges and the grid unfolds to match the input shape, this average distance falls and levels off.

Why do the Two Clusters and Spiral options look interesting?

They are not simply convex regions, so the grid cannot just stretch into a rectangle — it has to bend to follow disconnected clusters or a curling spiral arm while still keeping grid-adjacent neurons close together in weight space. Watching the mesh negotiate this tension is the clearest demonstration of topology preservation.

Is this a genuine Kohonen SOM implementation?

Yes. It implements the standard algorithm: competitive BMU selection by Euclidean distance, a Gaussian neighbourhood function evaluated on grid distance, and exponentially decaying learning rate and neighbourhood radius, matching the classic formulation used in the 3D colour version and in textbook Kohonen maps.

Where are self-organising maps used in practice?

SOMs are used for dimensionality reduction, exploratory clustering, and data visualisation — projecting high-dimensional data such as documents, images, or customer records onto a 2D grid where nearby cells represent similar inputs. This 2D-input version isolates exactly that projection behaviour without an extra colour-space translation step.