ML Train SOM

Unsupervised learning module based on a Self-Organizing Map (Kohonen network). Trains a 2D grid of neurons to reflect the topology of high-dimensional input data, then outputs the Best Matching Unit (BMU) position and a color visualization of the learned map.

A Self-Organizing Map (SOM) is an unsupervised neural network that projects high-dimensional data onto a low-dimensional (here 2D) grid while preserving topological relationships. Nearby neurons in the grid respond to similar input patterns. Over time, the map develops regions that cluster similar data points together, making it useful for dimensionality reduction, anomaly detection, and visualizing data structure.

Settings

Inputs

in

Array of float values representing one data sample. The length of the array determines the input dimension and is detected automatically on the first frame. Connect any sensor, feature vector, or multi-channel data source here.

learn

Switch. When ON, the map weights are updated at each process cycle using the current learning rate and neighborhood radius. When OFF, the module still finds and outputs the BMU but does not modify the map — useful for inference-only operation after training.

reset

Trigger. Clears all learned weights and hit counters, and resets the iteration counter to zero. The map will re-initialize from random weights on the next incoming frame.

Settings

grid width

Number of neurons along the horizontal axis of the map. Range 2 – 64, default 16. Changing this value triggers an automatic map reset.

grid height

Number of neurons along the vertical axis of the map. Range 2 – 64, default 16. Changing this value triggers an automatic map reset.

learn rate

Initial learning rate α₀. Controls how strongly the winning neuron and its neighbors are pulled toward each input sample. Range 0.001 – 1.0, default 0.1. The effective rate decays over time by the decay factor.

radius

Initial neighborhood radius σ₀. Defines how far (in grid cells) the influence of a BMU update spreads using a Gaussian kernel. Range 0.5 – 64, default 8. Decays over time by the decay factor, eventually focusing updates on the BMU alone.

decay

Multiplicative decay factor applied to both the learning rate and the neighborhood radius after each training step. Range 0.9 – 0.99999, default 0.999. Values close to 1 produce slow, gradual decay (long training runs); lower values converge faster but may under-train the map borders.

Outputs

bmu xy

Float array of length 2. Contains the [x, y] grid coordinates of the Best Matching Unit, normalized to [0, 1]. Connect to a 2D display, XY pad, or trajectory module to track input position on the map over time.

bmu id

Linear index of the BMU neuron: id = bmu_y × grid_width + bmu_x. Useful for direct lookup, routing, or discrete classification.

bmu distance

Euclidean distance in weight space between the input vector and the winning neuron's weight vector. Low values indicate a good match; high values indicate that the input is far from any learned cluster (novelty / anomaly indicator).

color map

Color array of length grid_width × grid_height. Each element is a color encoding determined by the selected viz mode. Connect to an Array Display module configured for 2D grid rendering (set its width to match grid width) for a live visualization.

iterations

Total number of training steps performed since the last reset. Useful for monitoring convergence or for triggering actions at specific training milestones.

Visualization

viz mode

Selects the rendering mode for the color map output.

Mode Description
u-matrix Each neuron is colored by the average Euclidean distance to its 4 direct neighbors (up, down, left, right). High values (warm colors) mark cluster boundaries; low values (cool colors) mark the interior of clusters. This is the standard SOM visualization.
hit map Each neuron is colored by how many times it was the BMU since the last reset. Bright areas show the most frequently activated neurons, revealing the density distribution of the training data.
bmu highlight Displays a dimmed U-Matrix as background and highlights the current BMU in white. Useful for real-time monitoring of which region of the map is currently activated.

Workflow

Training phase

  1. Connect your data source to in and set learn to ON.
  2. Let the map run until iterations stabilizes and the bmu distance settles to a low value.
  3. Monitor the color map output on an Array Display — distinct colored regions indicate that the map has learned clusters.

Inference phase

  1. Set learn to OFF to freeze the map.
  2. The module continues to output bmu xy, bmu id, and bmu distance for new incoming data without modifying the weights.
  3. Save your patch: the trained weights are persisted automatically in the patch file and restored on reload.

The map re-initializes automatically if the length of the in array changes (different input dimension). Always connect a data source with a consistent array length before training.

Learning rate and radius both decay continuously during training. After many iterations they approach zero, effectively halting learning even if learn is ON. Use reset to restart training with fresh weights and full initial rates.

Common Settings

info

show manual

Opens the web browser to display information or help about the selected object, if it exists.

For more details about information/help creation, see create-help-file.

description

Description of the module for internal help purposes only. The description is not displayed in the interface.

ID's

visible only in god mode, see setup-panel-tab-expert.

unique ID

Current private ID for this control used to identify the object.

preset ID

Current private preset ID for this control used for presets.

recreate ID

If you experience difficulties in Polyphonic mode, try to recreate new id(s) with this button.

repair ID s

Each Patch shared on the local network uses its own ID (identification number). If you experience issues of Patches that don't send information to the good target, this button will rebuild all these id's.

Object Remote Address

absolute

Absolute remote address. see objects-address.

local

Local to the current patch remote address. see objects-address.

user addr

User defined remote address. see objects-address.

See also

version 7.0.250121

Edit All Pages