Massively parallel implementation of self-organizing maps
Project description
Somoclu is a massively parallel implementation of self-organizing maps. It relies on OpenMP for multicore execution and it can be accelerated by CUDA. The topology of map is either planar or toroid, the grid is rectangular or hexagonal. Currently a subset of the command line version is supported with this Python module.
Key features of the Python interface:
Fast execution by parallelization: OpenMP and CUDA are supported.
Multi-platform: Linux, OS X, and Windows are supported.
Planar and toroid maps.
Rectangular and hexagonal grids.
Gaussian or bubble neighborhood functions.
Visualization of maps, including those that were trained outside of Python.
The documentation is available on Read the Docs. Further details are found in the manuscript describing the library [1].
Usage
A simple example is below. For more example, please refer to the documentation and a more thorough ipython notebook example at Somoclu in Python.ipynb.
import somoclu import numpy as np import matplotlib.pyplot as plt c1 = np.random.rand(50, 2)/5 c2 = (0.2, 0.5) + np.random.rand(50, 2)/5 c3 = (0.4, 0.1) + np.random.rand(50, 2)/5 data = np.float32(np.concatenate((c1, c2, c3))) colors = ["red"] * 50 colors.extend(["green"] * 50) colors.extend(["blue"] * 50) labels = list(range(150)) n_rows, n_columns = 30, 50 som = somoclu.Somoclu(n_columns, n_rows, data=data, maptype="planar", gridtype="rectangular") som.train(epochs=10) som.view_umatrix(bestmatches=True, bestmatchcolors=colors, labels=labels)
Installation
The code is available on PyPI, hence it can be installed by
$ sudo pip install somoclu
Some pre-built binaries in the wheel format or windows installer are provided at PyPI Dowloads, they are tested with Anaconda distributions. If you encounter errors like ImportError: DLL load failed: The specified module could not be found when import somoclu, you may need to use Dependency Walker as shown here on _somoclu_wrap.pyd to find out missing DLLs and place them at the write place. Usually right version (32/64bit) of vcomp90.dll, msvcp90.dll, msvcr90.dll should be put to C:\Windows\System32 or C:\Windows\SysWOW64.
The wheel binaries for OSX are compiled with clang-omp , and depend on libiomp5, which you can install by:
$ brew install libiomp
If you want the latest git version, first git clone the repo, install swig and run:
$ ./autogen.sh $ ./configure [options] $ make $ make python
to generate python interface files.
Then follow the standard procedure for installing Python modules:
$ sudo python setup.py install
Build on Mac OS X
Using GCC
Since OS X 10.9, gcc is just symlink to clang. To build somoclu and this extension correctly, it is recommended to install gcc using something like:
$ brew install gcc --without-multilib
and set environment using:
export CC=/usr/local/bin/gcc-5 export CXX=/usr/local/bin/g++-5 export CPP=/usr/local/bin/cpp-5 export LD=/usr/local/bin/gcc-5 alias c++=/usr/local/bin/c++-5 alias g++=/usr/local/bin/g++-5 alias gcc=/usr/local/bin/gcc-5 alias cpp=/usr/local/bin/cpp-5 alias ld=/usr/local/bin/gcc-5 alias cc=/usr/local/bin/gcc-5
Using clang-omp
To install clang-omp, follow instructions at http://clang-omp.github.io/. And set environment using:
export CC=/usr/local/bin/clang-omp export CXX=/usr/local/bin/clang-omp++ export CPP=/usr/local/bin/clang-omp++ export LD=/usr/local/bin/clang-omp alias c++=/usr/local/bin/clang-omp++ alias g++=/usr/local/bin/clang-omp++ alias gcc=/usr/local/bin/clang-omp alias cpp=/usr/local/bin/clang-omp++ alias ld=/usr/local/bin/clang-omp alias cc=/usr/local/bin/clang-omp export PATH=/usr/local/bin/:$PATH export C_INCLUDE_PATH=/usr/local/include/:$C_INCLUDE_PATH export CPLUS_INCLUDE_PATH=/usr/local/include/:$CPLUS_INCLUDE_PATH export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Before building the module manually with:
$ python setup.py build
Build with CUDA support on Linux and OS X:
If the CUDAHOME variable is set, the usual install command will build and install the library:
$ sudo python setup.py install
Build with CUDA support on Windows:
You should first follow the instructions to build the Windows binary with HAVE_MPI and CLI disabled with the same version Visual Studio as your Python is built with.(Since currently Python is built by VS2008 by default and CUDA v6.5 removed VS2008 support, you may use CUDA 6.0 with VS2008 or find a Python prebuilt with VS2010. And remember to install VS2010 or Windows SDK7.1 to get the option in Platform Toolset if you use VS2013.) The recommended configuration is VS2010 Platform Toolset with Python 3.4. Then you should copy the .obj files generated in the release build path to the Python\somoclu\src folder.
Then modify the environment variable CUDA_PATH or win_cuda_dir in setup.py to your CUDA path and run the install command
$ sudo python setup.py install
Then it should be able to build and install the module.
Citation
Peter Wittek, Shi Chao Gao, Ik Soo Lim, Li Zhao (2015). Somoclu: An Efficient Parallel Library for Self-Organizing Maps. arXiv:1305.1422.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for somoclu-1.7.0.win-amd64-py3.5.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90c8c5f740e81c936d70007f5d59465c29a99395b11ee04403c348cf951d4465 |
|
MD5 | 4cf000990edf57a758446eaa23cb5b50 |
|
BLAKE2b-256 | 5617b9707a131a305442166b6c3abc4f07bdea48481530cb71e6ca8fd54bcc37 |
Hashes for somoclu-1.7.0.win-amd64-py2.7.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 033ce5e0b124431a63b3ecc769bed051f239d70520bca5a8a1b48276094ddad6 |
|
MD5 | b3336bfade95f63c2fee22bad8b54152 |
|
BLAKE2b-256 | 4bbca3e386446e6029fdf3065f82d2b8b7ef2495f02f29462f65b4b199989b98 |
Hashes for somoclu-1.7.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02c7800e6932edfb43614e9488a1429b3d25a76fdf82abca14b7a976351a90b4 |
|
MD5 | 20f1a456fc2ac181c821f0fcb20f73e1 |
|
BLAKE2b-256 | c7d0ed4762d77913c12f737b4cffdcf76feb76cedcd938ab20ce164e1fb6a072 |
Hashes for somoclu-1.7.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9cd6db02454329ca5ea1a39fa5f33841c4bd13a6957f21edc43d22ab513b792 |
|
MD5 | 86ff98e3e5e462aaaac2c04823cfc8b3 |
|
BLAKE2b-256 | 1ffa8d26cb19fe0722690c1f11c64c6698a44dc4e2b7f1918d2ed1842b2bd03b |
Hashes for somoclu-1.7.0-cp35-cp35m-macosx_10_6_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0976e0d384d8740bf96a54bcdfe63f621c14e0a58b0abb8019b4d79eb6bfad1 |
|
MD5 | abf7a6255eaa45ba6b75de85f0aa4c06 |
|
BLAKE2b-256 | 557f97bfa18893f5a453c6b3e9b929074733911f15e86f334fcd96d0acbeee34 |
Hashes for somoclu-1.7.0-cp34-cp34m-macosx_10_5_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c549787073a2fc0cb0040e803cbd0277c09e0b1f5ccfc050538001c23c926080 |
|
MD5 | 153335002dec45a14e3235eb930af2b4 |
|
BLAKE2b-256 | d4a570e6c1bd11bc590c4541f3038274f40d1fef51df41ab7820e6698db6a55e |
Hashes for somoclu-1.7.0-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbaaf8af71c0732ebd8c37bed71d684a901f2e579153962bad44978c8b62c07c |
|
MD5 | 8e0a0cd6738d86391429e3218d6128f8 |
|
BLAKE2b-256 | 213b6e333f99588edd8b9ea163826a42b91b8826d5489885aa0ffac2bece6e92 |
Hashes for somoclu-1.7.0-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c7ad14323b58fd50e3f9cd3a50e6193f946e0cec6b1f4cbc1b8682473bb045 |
|
MD5 | 73daa425ac1da189f12b118b9ebda506 |
|
BLAKE2b-256 | 1b6d54aa97f4644460d2ccfd2843abe7f6056e09cb01a1155b860ef785f82ce8 |
Hashes for somoclu-1.7.0-cp27-cp27m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71bc3441f78f969b504a2927366362fb8f055ba06171e8bc3a4cb315543f0334 |
|
MD5 | a771a4b4a353f63f14fb2c0cd617f2af |
|
BLAKE2b-256 | 1c0c7ba1ed3a0b46f87135c8babfac945d6bb4bda74555168fab3d29773e5e3d |