TorchSOM Documentation

TorchSOM is a modern PyTorch-based library for training and visualizing Self-Organizing Maps (SOMs), a powerful unsupervised learning algorithm used for clustering, dimensionality reduction, and data exploration.

Built with PyTorch at its core, TorchSOM seamlessly integrates with modern deep learning workflows while providing GPU acceleration for high-performance computing.

Note

🌟 If you find this project interesting, we would be grateful for your support by starring this GitHub repository.

Key Features

🚀 Performance
  • GPU-accelerated training with PyTorch

  • Efficient batch processing and memory management

  • Optimized for large-scale data

🎯 Flexibility
  • Multiple SOM variants (classical, growing, hierarchical, …)

  • Configurable topologies (rectangular, hexagonal)

  • Extensive customization options

📊 Visualization
  • Rich visualization suite with matplotlib

  • Publication-ready figures

🔧 Developer-Friendly
  • Clean, modular architecture

  • Comprehensive API documentation

  • Type hints and validation with Pydantic

Quick Start

Install TorchSOM:

pip install torchsom

Basic usage:

import torch
from torchsom.core import SOM
from torchsom.visualization import SOMVisualizer,

# Create a 10x10 map for 3D input
som = SOM(x=10, y=10, num_features=3, epochs=50)

# Train SOM for 50 epochs on 1000 samples
X = torch.randn(1000, 3)
som.initialize_weights(data=X, mode="pca")
QE, TE = som.fit(data=X)

# Visualize results
visualizer = SOMVisualizer(som=som, config=None)
visualizer.plot_training_errors(quantization_errors=QE, topographic_errors=TE, save_path=None)
visualizer.plot_distance_map(save_path=None)
visualizer.plot_hit_map(data=X, save_path=None)

Documentation Structure

Support & Community

  • 📖 Documentation: You’re reading it!

  • 🐛 Bug Reports: GitHub Issues

License

TorchSOM is released under the Apache License 2.0 License. See the LICENSE file for details.

Indices and Tables