Skip to content

This repository implements the Kohonen method, also known as Self-Organizing Maps (SOM), to demonstrate its ability to map data to various spaces, and provides a visual representation of the process.

Notifications You must be signed in to change notification settings

GonzaloHirsch/kohonen-space-mapping

Repository files navigation

Kohonen Space Mapping

Example of Kohonen working as a Self-Organizing Map.

The implementation of Kohonen is a modified version of MiniSom. The difference is an exposed method to apply the training in steps to be able to hook up to that and visualize the process.

Setting Up

Create a virtual environment and install all dependencies:

virtualenv .env
source .env/bin/activate
pip install -r requirements.txt

Execution

Kohonen Method

To run the method, the command is:

python main.py -n KOHONEN_SIZE -it ITERATIONS -nd SPACE_POINTS -fig grid|circle|triangle|random-circle -line
  • -n --> Size of the network (n x n)
  • -it --> Number of iterations to use
  • -nd --> Total points to attempt to adjust to (should be perfect square, ie, 25, 36, 49, etc) within the range [-1, 1]
  • -fig --> Point distribution to use.
  • -line --> Enables or disables drawing lines between Kohonen points.

Example call:

python main.py -n 5 -it 3000 -nd 25 -fig grid 

Image to GIF

To run the method, the command is:

python image_to_gif.py -f FOLDER_PATH -s STEPS_IN_GIF
  • -f --> Path to folder with images
  • -s --> Frames to skip in every iteration, it's the step

Example call:

python image_to_gif.py -f results/5-3000-25 -s 10

Image to Video

To run the method, the command is:

python image_to_video.py -f FOLDER_PATH -s STEPS_IN_GIF -fps VIDEO_FPS
  • -f --> Path to folder with images
  • -s --> Frames to skip in every iteration, it's the step
  • -fps --> FPS for the video

Example call:

python image_to_video.py -f results/5-3000-25 -s 1 -fps 60

About

This repository implements the Kohonen method, also known as Self-Organizing Maps (SOM), to demonstrate its ability to map data to various spaces, and provides a visual representation of the process.

Topics

Resources

Stars

Watchers

Forks

Languages