Skip to main content
Help us improve Python packaging – donate today!

a cluster-oriented implementation of self-organizing maps

Project Description

Somoclu is a massively parallel implementation of self-organizing maps. It relies on OpenMP for multicore execution, MPI for distributing the workload, and it can be accelerated by CUDA on a GPU cluster. A sparse kernel is also included, which is useful for training maps on vector spaces generated in text mining processes. The topology of the grid is rectangular.

Currently a subset of the C++ version is supported with this package.


Example, in which the data file rgbs.txt can be found at

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import somoclu
import numpy as np

data = np.loadtxt('rgbs.txt')
data = np.float32(data)
nSomX = 50
nSomY = 50
nVectors = data.shape[0]
nDimensions = data.shape[1]
data1D = np.ndarray.flatten(data)
nEpoch = 10
radius0 = 0
radiusN = 0
radiusCooling = "linear"
scale0 = 0
scaleN = 0.01
scaleCooling = "linear"
kernelType = 0
mapType = "planar"
snapshots = 0
initialCodebookFilename = ''
codebook_size = nSomY * nSomX * nDimensions
codebook = np.zeros(codebook_size, dtype=np.float32)
globalBmus_size = int(nVectors * int(np.ceil(nVectors/nVectors))*2)
globalBmus = np.zeros(globalBmus_size, dtype=np.intc)
uMatrix_size = nSomX * nSomY
uMatrix = np.zeros(uMatrix_size, dtype=np.float32)
somoclu.trainWrapper(data1D, nEpoch, nSomX, nSomY,
                     nDimensions, nVectors,
                     radius0, radiusN,
                     radiusCooling, scale0, scaleN,
                     scaleCooling, snapshots,
                     kernelType, mapType,
                     codebook, globalBmus, uMatrix)
print codebook
print globalBmus
print uMatrix

Get it now

$ sudo pip install somoclu

Build on Mac OS X:

Before installing using pip, gcc should be installed first. As of 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 gcc48

and set environment using:

export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++
export CPP=/usr/local/bin/cpp
export LD=/usr/local/bin/gcc
alias c++=/usr/local/bin/c++
alias g++=/usr/local/bin/g++
alias gcc=/usr/local/bin/gcc
alias cpp=/usr/local/bin/cpp
alias ld=/usr/local/bin/gcc
alias cc=/usr/local/bin/gcc

Then you can

$ sudo pip install somoclu

Build with CUDA support on Linux:

You need to clone this repo or download the latest release tarball, and

$ cd src/Python
$ bash

Then if your CUDA installation is located at /opt/cuda and 64bit, you can do the following to install:

$ sudo python2 install

Otherwise, you should modify the , change the path to CUDA installation accordingly:

call(["./configure", "--without-mpi","--with-cuda=/opt/cuda/"])



Then run the install command

$ sudo python2 install

Then you can use the python interface like before, with CUDA support.

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node

History Node


History Node

History Node


This version
History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
somoclu-1.4-py2.7-win-amd64.egg (33.0 kB) Copy SHA256 hash SHA256 Egg 2.7 Oct 17, 2014
somoclu-1.4.tar.gz (55.3 kB) Copy SHA256 hash SHA256 Source None Oct 17, 2014 (32.7 kB) Copy SHA256 hash SHA256 Windows Installer 2.7 Oct 17, 2014 (76.2 kB) Copy SHA256 hash SHA256 Source None Oct 17, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page