/fast-som

A PyTorch implementation of 2D SOM (Self Organizing Map) that runs fast.

Primary LanguagePythonMIT LicenseMIT

A PyTorch implementation of 2D SOM (Self Organizing Map) that runs fast.

The code is largely based on the original TensorFlow-implementation by Google engineer Sachin Joglekar's in his blogpost.

Screenshot

Here is the mandatory screenshot.

Screenshot 1

Why?

Although I could find--at the time of this writing--another implementation of a 2D-SOM in PyTorch in this repository which was also heavily based on the original TensorFlow implementation, the PyTorch code ran too slowly.

So, here's an implementation that runs fast (relatively). Enjoy! 👍

Usage

The som.py file contains the class definition of a 2D-SOM. Feel free to tweak it to your needs.

The colorsome.py file showcases a nice example of using the SOM2D class from som.py to cluster the RGB color space.