API Reference

The public API is small by design. Most workflows use the SOM class, the SOMVisualizer, and (optionally) the SOMConfig. The pages below document every module in full.

Core

torchsom.core — the SOM class and its BaseSOM interface.

Core API
Utils

torchsom.utils — distances, neighborhoods, decay, clustering, metrics, search.

Utilities API
Visualization

torchsom.visualizationSOMVisualizer and VisualizationConfig.

Visualization API
Configs

torchsom.configs — the Pydantic SOMConfig model.

Configuration API

Public objects at a glance

Object

Purpose

torchsom.core.SOM

The Self-Organizing Map: fit, build_map, cluster, collect_samples.

torchsom.core.BaseSOM

Abstract base defining the SOM interface and shared attributes.

torchsom.visualization.SOMVisualizer

Factory that renders every plot for the SOM’s topology.

torchsom.visualization.VisualizationConfig

Styling options for figures (size, fonts, colormap, DPI, hex settings).

torchsom.configs.SOMConfig

Validated, serializable configuration for a SOM.

torchsom.DISTANCE_FUNCTIONS

Registry of distance metrics (euclidean, cosine, manhattan, chebyshev).

torchsom.NEIGHBORHOOD_FUNCTIONS

Registry of neighborhood kernels (gaussian, mexican_hat, bubble, triangle).

torchsom.DECAY_FUNCTIONS

Registry of learning-rate and neighborhood-width decay schedules.

Import conventions

The most common objects are re-exported at the top level:

from torchsom import SOM, SOMVisualizer
from torchsom.visualization import VisualizationConfig
from torchsom.configs import SOMConfig

The function registries let you list or extend the available options:

from torchsom import DISTANCE_FUNCTIONS, NEIGHBORHOOD_FUNCTIONS, DECAY_FUNCTIONS

print(list(DISTANCE_FUNCTIONS))       # available distance metrics
print(list(NEIGHBORHOOD_FUNCTIONS))   # available neighborhood kernels

See also

The Package Architecture page explains how these modules fit together, and the Training guide maps the constructor arguments to training behavior.