Self-orgnizing Map

blog
code

image.png

The intuition behaind is

  1. The neural network outputs vectors in lower dimension.
  2. Read the input one-by-one, and compute their representation in lower dimension.
  3. Find the closest vector and move the representation towards the closest vector with gradient.
In [1]:
data = [[ 0.80,  0.55,  0.22,  0.03],
        [ 0.82,  0.50,  0.23,  0.03],
        [ 0.80,  0.54,  0.22,  0.03],
        [ 0.80,  0.53,  0.26,  0.03],
        [ 0.79,  0.56,  0.22,  0.03],
        [ 0.75,  0.60,  0.25,  0.03],
        [ 0.77,  0.59,  0.22,  0.03]]  
In [2]:
from minisom import MiniSom    
som = MiniSom(6, 6, 4, sigma=0.3, learning_rate=0.5) # initialization of 6x6 SOM
som.train(data, 100) # trains the SOM with 100 iterations
In [3]:
som.winner(data[-1])
Out[3]:
(4, 5)