Self-Organizing Maps with fast.ai

or: how I learned to stop worrying and love the SOM

Riccardo Sayn
Kirey Group
2 min readJul 8, 2020

--

15x15 Self-Organizing Map trained on RGB Colors

Earlier this year, I started my coding journey in Machine Learning by taking the Practical Deep Learning for Coders course by Jeremy Howard. The part 2 of the course focused on how the basic moving pieces of the Fast.ai library are implemented.

As an exercise, I decided to develop and integrate a neural network architecture that wasn’t natively available inside the library.

My choice fell on Self-Organizing Maps, mainly because I feel they deserve more love, but also because I had to use them for some of my work projects and I wasn’t able to find an implementation that suited our needs.

As many SOM implementations didn’t have GPU support, batching and/or custom distance functions, I decided to start from there; I also wanted something that was as simple to use as the native Fast.ai APIs.

In the end, I had so much fun writing the code and seeing it work that I went overboard and I ended up with a set of ready-to-use tools and interpretation utilities.

In this series, I will go over the steps I took in building each component and wiring everything together.

I’m really happy with the final result, as it runs really fast and it turned out to be very simple to use and customize:

PCA visualization of a SOM training on the House Prices dataset

If you can’t wait or if you want to have a look at the final code, it can be found in this Github repository or as an installable package on PyPi.

--

--