Skip to main content

torchsom: The Reference PyTorch Library for Self-Organizing Maps

Project description

TorchSOM: The Reference PyTorch Library for Self-Organizing Maps

PyPI version Python versions PyTorch versions

Tests Code Quality

Code style: black Imports: isort License: Apache 2.0

TorchSOM_logo

The most comprehensive, scalable, and PyTorch-native implementation of Self-Organizing Maps

📚 Documentation | 🚀 Quick Start | 📊 Examples | 🤝 Contributing


🎯 Why TorchSOM?

TorchSOM is the reference PyTorch library for Self-Organizing Maps (SOMs), purpose-built for seamless integration with modern deep learning and scientific workflows. Unlike legacy SOM packages, TorchSOM is engineered from the ground up to fully leverage PyTorch’s ecosystem—offering native GPU acceleration, scalable performance, and compatibility with neural network pipelines. Whether you are a researcher or practitioner, TorchSOM empowers you to efficiently incorporate SOMs into your machine learning projects, from exploratory data analysis to advanced model architectures.

TorchSOM is the official implementation accompanying the paper: TorchSOM: A Scalable PyTorch-Compatible Library for Self-Organizing Maps, presented at @CONFERENCE, @DATE.

⭐ If you find TorchSOM valuable, please consider starring this repository ⭐

⚡ Key Advantages

Feature TorchSOM MiniSom SOMPY SOMToolbox
🖥️ Code Compatibility Python Python Python MATLAB
🚀 GPU Acceleration
🔥 PyTorch Integration
📈 Scalability ⚠️ Limited ⚠️ Limited Unknown
🧩 Deep Learning Compatible
🌱 Growing SOM 🚧 Building
🏗️ Hierarchical SOM 🚧 Building
📊 Rich Visualizations
🔬 Active Development ⚠️ (small updates)

📑 Table of Contents


🚀 Quick Start

Get started with TorchSOM in just a few lines of code:

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)

📓 Examples

Explore our comprehensive collection of Jupyter notebooks:

🎨 Some visualizations

🗺️ D-Matrix Visualization

Michelin production line (regression)

U-Matrix
📍 Hit Map Visualization

Michelin production line (regression)

Hit Map
📊 Mean Map Visualization

Michelin production line (regression)

Mean Map
🎯 Component Planes Visualization

Another Michelin line (regression)

Component Plane 1 Component Plane 2
🏷️ Classification Map

Wine dataset (multi-classification)

Classification Map


💾 Installation

📦 PyPI (not yet available)

pip install torchsom

🔧 Development Version

git clone https://github.com/michelin/TorchSOM.git
cd TorchSOM
python3.9 -m venv .torchsom_env
source .torchsom_env/bin/activate
pip install -e ".[dev]"

📚 Documentation

Comprehensive documentation is available at michelin.github.io/TorchSOM


📝 Citation

If you use TorchSOM in your research, please cite both the paper and software:

@inproceedings{Berthier2025TorchSOM,
    title={TorchSOM: A Scalable PyTorch-Compatible Library for Self-Organizing Maps},
    author={Berthier, Louis},
    booktitle={Conference Name},
    year={2025}
}

@software{Berthier_TorchSOM_The_Reference_2025,
    author={Berthier, Louis},
    title={TorchSOM: The Reference PyTorch Library for Self-Organizing Maps},
    url={https://github.com/michelin/TorchSOM},
    version={1.0.0},
    year={2025}
}

For more details, please refer to the CITATION.cff file.


🤝 Contributing

We welcome contributions from the community! See our Contributing Guide and Code of Conduct for details.


🙏 Acknowledgments


📄 License

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


📚 References

📖 Core Papers

🔗 Related Projects


If you find TorchSOM useful, please ⭐ star this repository!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchsom-0.0.1.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchsom-0.0.1-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file torchsom-0.0.1.tar.gz.

File metadata

  • Download URL: torchsom-0.0.1.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for torchsom-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d49cefa84500d819f3e67cb7a7a8fcd38d07799a6b298630e41b739db1a30380
MD5 f779329d801f703e6cdfa375a5840a2f
BLAKE2b-256 ffe03b78db3da50a42277201023b0b41645ed33468f0036cd6676a439c946d95

See more details on using hashes here.

File details

Details for the file torchsom-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: torchsom-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for torchsom-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32c72194485160c23fe98504f7f65dba50c5a32e9813496c067f9beea9c05415
MD5 19711e701626ad9428ba1000f6bd0585
BLAKE2b-256 42ee29345cc822fc26af4399768a125b627847172561621c0a549cfad553c940

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page