spiglerg / Kohonen_SOM_Tensorflow

Tensorflow implementation of the Kohonen Self Organizing Map
60 stars 15 forks source link

basic usage `SOM()` method and `dim` #2

Open kevglynn opened 6 years ago

kevglynn commented 6 years ago

I am trying to implement self-organizing maps in python, ideally in tensorflow. Thanks for your efforts here!

When using SOM() with anything other than dim=3 doesn't seem to work. I even adjusted the inputs to be an array of shape (10, 2), but maybe I'm off here?

Any help you can offer is greatly appreciated. If you need to see code, please let me know. My hope is to eventually be able to apply SOM to an arbitrarily large feature space on a large number of observations/rows. Thanks!

spiglerg commented 6 years ago

It works for me. What code are you using?

I've just tried it with: s = SOM( (4,), 30, num_training, sess ) and supplying 4 dimensional vectors (I've added a 4th component to all the vectors I was using in the example to test the training).

Clearly, the visualization part of the code not work as it visualizes 3D weights as RGB values in a picture. If you use more than 3 dimensions, you can only visualize up to 3 dimensions at a time in a picture, for example by picking the first 3 components of the weights vectors: plt.imshow( np.reshape(s.get_weights()[:,0:3], [30, 30, 3]) )