{"id":20684085,"url":"https://github.com/silkodenis/som","last_synced_at":"2025-04-22T12:31:58.439Z","repository":{"id":237006191,"uuid":"132938309","full_name":"silkodenis/SOM","owner":"silkodenis","description":"Neural network with learning without a teacher, performing the task of visualization and clustering.","archived":false,"fork":false,"pushed_at":"2019-08-18T14:21:21.000Z","size":50135,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T15:11:26.095Z","etag":null,"topics":["c-plus-plus","computer-vision","machine-learning","ml","neural-network","opencl","opencv","parallel-computing","self-organizing-map","som"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silkodenis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-10T18:17:47.000Z","updated_at":"2024-10-29T22:36:19.000Z","dependencies_parsed_at":"2024-04-29T16:07:44.523Z","dependency_job_id":"1996374d-d3b2-4ac8-a51f-ac1ca3bf57b9","html_url":"https://github.com/silkodenis/SOM","commit_stats":null,"previous_names":["silkodenis/som"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silkodenis%2FSOM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silkodenis%2FSOM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silkodenis%2FSOM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silkodenis%2FSOM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silkodenis","download_url":"https://codeload.github.com/silkodenis/SOM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250240960,"owners_count":21397895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","computer-vision","machine-learning","ml","neural-network","opencl","opencv","parallel-computing","self-organizing-map","som"],"created_at":"2024-11-16T22:19:03.388Z","updated_at":"2025-04-22T12:31:58.414Z","avatar_url":"https://github.com/silkodenis.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Self-Organizing Map (SOM)\n\nFast and most complete C++ library using parallel computing based on OpenCL. The map has a hexagon cells, which allows you to get the correct model view. All this makes it possible to use the library for high-level scientific works.\n\n## Installation on a Unix-based OS\nRequired Packages:\n* `CMake 2.8` or higher\n* `Git`\n\nDependencies:\n* `OpenCL 1.2 `  \n* `OpenCV 3` [optional] (for build view and examples)\n\nThese steps have been tested for macOS Mojave 10.14 but should work with other unix-based systems as well.\n\n### Install\n\n```sh\n1. $ cd ~/\u003cmy_working_directory\u003e\n2. $ git clone --branch v1.0 https://github.com/silkodenis/SOM.git\n3. $ cd SOM\n4. $ mkdir build\n5. $ cd build\n```\n\n```sh\n## to build som, view and examples\n6. $ cmake -D CMAKE_INSTALL_PREFIX=/usr/local ..\n\n## to build only lib som\n6. $ cmake -D CMAKE_INSTALL_PREFIX=/usr/local ../som\n```\n\n```sh\n7. $ make\n8. $ make test\n9. $ sudo make install\n```\n\n### Uninstall\n\n```sh\n9. $ sudo make uninstall\n```\n\n### Notes\n```sh\n## to generate XCode projects use:\n6. $ cmake -G Xcode ..\n```\n\n```sh\n## to build dynamic libs, use option: [-D BUILD_SHARED_LIBS=true], for example:\n6. $ cmake -D BUILD_SHARED_LIBS=true -D CMAKE_INSTALL_PREFIX=/usr/local ..\n```\n\n## Examples\nBelow is a brief overview of the examples, the [source code](https://github.com/silkodenis/SOM/tree/master/examples) of which gives a quick start to work with SOM.\n\n**Simple training**\n\nHello world!\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"412\" height=\"355\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/simple%20training/untrained_map.png?raw=true\"\u003e\n\n\u003cimg width=\"412\" height=\"355\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/simple%20training/trained_map.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Real-time training**\n\nA simple example of how to training SOM and get a model view in real time.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"568\" height=\"649\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/real-time%20training/training_proccess.gif?raw=true\"\u003e\n\u003c/p\u003e\n\n**Data approximation**\n\nA simple example of using one-dimensional SOM for data approximation.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"650\" height=\"650\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/regression/training_process.gif?raw=true\"\u003e\n\u003c/p\u003e\n\n**Image as dataset**\n\nThis example demonstrate using image as a data set. After receiving the clustered map from one image, we apply it to clustering another image.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"800\" height=\"531\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/image%20as%20dataset/image_as_dataset_target%20mat.png?raw=true\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"363\" height=\"347\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/image%20as%20dataset/image_as_dataset_training%20mat.png?raw=true\"\u003e\n\n\u003cimg width=\"405\" height=\"350\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/image%20as%20dataset/image_as_dataset_trained%20SOM.png?raw=true\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"800\" height=\"531\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/image%20as%20dataset/image_as_dataset_processed%20mat.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Single channel analysis**\n\nA simple example of analyzing the channels of a trained map. \n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"283\" height=\"324\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/single%20channel%20analysis/rgb_map.png?raw=true\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"849\" height=\"324\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/single%20channel%20analysis/single_channel_maps.png?raw=true\"\u003e\n\u003c/p\u003e\n\n\n**Deep analysis**\n\nThis example demonstrates various model view interpretations of a trained map.\n\n* Convolution maps, 3D(rgb) + 1D(v).\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"854\" height=\"489\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/deep%20analysis/convolution%203d%20+%201d.png?raw=true\"\u003e\n\u003c/p\u003e\n\n* Maps of accumulated distances during training.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"854\" height=\"489\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/deep%20analysis/distances.png?raw=true\"\u003e\n\u003c/p\u003e\n\n* Maps from nodes that have been activated during training.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"854\" height=\"489\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/deep%20analysis/actives%20only%203d%20+%201d.png?raw=true\"\u003e\n\u003c/p\u003e\n\n* Approximation maps. The temperature of the node indicates the frequency of activation during training.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"854\" height=\"489\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/deep%20analysis/approximation%20gradient%20+%20hue.png?raw=true\"\u003e\n\u003c/p\u003e\n\n* Single channel maps. These maps show how the resulting clusters depend on the components of the vectors used in training.\n  \n\u003cp align=\"center\"\u003e  \n\u003cimg width=\"600\" height=\"571\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/deep%20analysis/channels.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Debug training process**\n\nThis example demonstrate dynamics of map error on the expiration of training epochs. It's important to timely stop training to avoid problem of overfitting. Observation of the convergence dynamics will help you to justify some learning parameters.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"800\" height=\"600\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/training%20process/training_process.gif?raw=true\"\u003e\n\u003c/p\u003e\n\n**Save and load**\n\nA simple demonstration of saving and loading your model from a binary file.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"742\" height=\"643\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/examples/save%20and%20load/som.png?raw=true\"\u003e\n\u003c/p\u003e\n\n## Distance Metrics\n\nDistance metrics can be very importance in the data analyzing using SOM. At the core of learning algorithm is activation(by computing distances from nodes weights to input vector) of the Best Matching Unit. BMU in turn will affect change the weights of its neighbors. The library provides 10 most popular distance metrics:\n\nDefinition:\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"351\" height=\"17\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/definition.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Euclidean:**\n\nIt is the natural distance in a geometric interpretation and is classic for many solution.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"374\" height=\"58\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/euclidean.png?raw=true\"\u003e\n\u003c/p\u003e\n\n\n**Minkowski:**\n\nIs the generalized Lp-norm of the difference. Can be considered as a generalization of both the Euclidean distance the case of p=2 and the Manhattan distance the case of p=1. \n\u003cp align=\"center\"\u003e\n\u003cimg width=\"272\" height=\"54\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/minkowski.png?raw=true\"\u003e  \n\u003c/p\u003e\n\n**Chebyshev:**\n\nMinkowski distance with limiting case of p reaching infinity.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"414\" height=\"54\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/chebyshev.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Manhattan(Taxicab):**\n\nSpecial case of the Minkowski distance with p=1 and equivalent to the sum of absolute difference. Also known as Taxicab norm, rectilinear distance or L1-norm. Used in regression analysis since the 18th century.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"230\" height=\"44\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/manhattan.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Canberra:**\n\nIt is a weighted version of Manhattan distance. Is often used for data scattered around an origin, as it is biased for measures around the origin and very sensitive for values close to zero.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"232\" height=\"44\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/canberra.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Cosine:**\n\nRepresents the angular distance while ignoring space scale. Is most commonly used in high-dimensional positive spaces and also to measure cohesion within clusters in the field of data mining.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"265\" height=\"90\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/cosine.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Sum of Absolute Difference(SAD):**\n\nIs equivalent to the L1-norm of the difference, also known as Manhattan or Taxicab-norm. The abs function makes this metric a bit complicated, but it is more robust than SSD.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"193\" height=\"44\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/SAD.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Sum of Squared Difference(SSD):**\n\nIs equivalent to the squared L2-norm, also known as Euclidean norm. It is therefore also known as Squared Euclidean distance. Squares cause it to be very sensitive to large outliers. Is a standard approach in regression analysis.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"199\" height=\"44\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/SSD.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Mean-Absolute Error(MAE):**\n\nIs a normalized version SAD.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"212\" height=\"44\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/MAE.png?raw=true\"\u003e\n\u003c/p\u003e\n\n**Mean-Squared Error(MSE):**\n\nIs a normalized version SSD.\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"220\" height=\"44\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/distance%20metrics/MSE.png?raw=true\"\u003e\n\u003c/p\u003e\n\n## Pseudocolor Schemes\n\nView has 20 most popular Matlab and Matplotlib equivalent colormaps.\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"620\" height=\"711\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/pseudocolor%20schemes/colormaps.gif?raw=true?raw=true\"\u003e\n\u003c/p\u003e\n\nThe colormap have three parameters for adjustment (inversion, colors quantization and limits).\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"701\" height=\"711\" src=\"https://github.com/silkodenis/SOM/blob/readme_assets/pseudocolor%20schemes/colormap%20configure.gif?raw=true?raw=true?raw=true\"\u003e\n\u003c/p\u003e\n\n\n## Authors\n\n* **Denis Silko** - *Initial work* - [silkodenis](https://github.com/silkodenis)\n\n## Credits\n\nThanks to [Amit Patel](http://www-cs-students.stanford.edu/~amitp/) for help in implementing the efficient hexagonal grid.\n\n## License\n\n[Apache License 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilkodenis%2Fsom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilkodenis%2Fsom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilkodenis%2Fsom/lists"}