Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Protected Attributes
icl::math::SOM Class Reference

Generic implementation of D to K dim Self Organizing Map (SOM) More...

#include <SOM.h>

Inheritance diagram for icl::math::SOM:
icl::math::SOM2D

List of all members.

Classes

struct  Neuron
 SOM internal Neuron struct. More...

Public Member Functions

 SOM (unsigned int dataDim, const std::vector< unsigned int > &dims, const std::vector< utils::Range< float > > &prototypeBounds, float epsilon=0.1, float sigma=1)
 create a new SOM with given data dimension and grid dimensions.
 ~SOM ()
 Destructor.
void train (const float *input)
 trains the net using given input vector and current parameters epsilon and sigma
const NeurongetWinner (const float *input) const
 returns a reference of the winner neuron dependent on a given input vector (const)
NeurongetWinner (const float *input)
 returns a reference of the winner neuron dependent on a given input vector
const std::vector< Neuron > & getNeurons () const
 returns the neuron set (const)
std::vector< Neuron > & getNeurons ()
 returns the neuron set
const NeurongetNeuron (const std::vector< int > &dims) const
 returns a neuron at given grid location (const)
NeurongetNeuron (const std::vector< int > &dims)
 returns a neuron at given grid location
unsigned int getDataDim () const
 returns the data dimension
unsigned int getSomDim () const
 returns the SOM dimension (e.g. 2D, 3D ..)
const std::vector< unsigned int > getDimensions () const
 returns the SOM's grid dimension (e.g. 20x40 for a 2D SOM)
void setEpsilon (float epsilon)
 sets the current learning rate epsilon
void setSigma (float sigma)
 sets the current grid distance function standard deviation

Protected Attributes

unsigned int m_uiDataDim
 internal data dimension variable
unsigned int m_uiSomDim
 internal SOM dimension variable ( = m_vecPrototypeBounds.size() = m_vecDimensions.size() )
std::vector< unsigned int > m_vecDimensions
 internal grid dimensions
std::vector< utils::Range
< float > > 
m_vecPrototypeBounds
 internal bounds for prototype ranges (todo: is it necessary to store them ?)
std::vector< Neuronm_vecNeurons
 set of neurons
std::vector< unsigned int > m_vecDimOffsets
 internal utility offset vector for each dimension
float m_fEpsilon
 learning rate
float m_fSigma
 standard deviation for the grid distance function

Detailed Description

Generic implementation of D to K dim Self Organizing Map (SOM)

Input dimension as well as output dimension is freely configurable, i.e. SOM neurons can be aligned in a K dimensional grid with arbitrary cell count for each dimension. For more convenience an inline wrapper class called SOM2D is also available in "iclSOM2D.h"

Nomenclature

Prototype Update

\[ \forall r \in \{1,...,n\} \\ \Delta n_r.p = \epsilon \cdot h(n_r.g,h_s.g) \cdot (x-n_r.p) \]

Grid distance function ( $h$)

\[ h(a,b) = e^{-\frac{(a-b)^2}{s\sigma^2}} \]


Constructor & Destructor Documentation

icl::math::SOM::SOM ( unsigned int  dataDim,
const std::vector< unsigned int > &  dims,
const std::vector< utils::Range< float > > &  prototypeBounds,
float  epsilon = 0.1,
float  sigma = 1 
)

create a new SOM with given data dimension and grid dimensions.

Parameters:
dataDimdimension of data elements and prototype vectors
dimsgrid dimension array. dims.size() defines the SOM'S grid dimension. dims[i] defines the cell count for dimension i. E.g. to create a 2D 40x40 SOM grid dims has to be $\{40,40\}$.
prototypeBoundsInternals for new randomly created prototype vector elements. prototypeBounds.size() must be equal to dataDim. E.g. to initialize a SOM with prototypes randomly distributed in a dataDim-D unity cube $[-1,1]^{dataDim}$, prototypeBounds must be $\{(-1,1),(-1,1),...\}$ (where the ranges are written as tuples).
epsiloninitial learning rate
sigmainitial standard deviation for the grid distance function $h(a,b)$

Destructor.


Member Function Documentation

unsigned int icl::math::SOM::getDataDim ( ) const [inline]

returns the data dimension

const std::vector<unsigned int> icl::math::SOM::getDimensions ( ) const [inline]

returns the SOM's grid dimension (e.g. 20x40 for a 2D SOM)

const Neuron& icl::math::SOM::getNeuron ( const std::vector< int > &  dims) const

returns a neuron at given grid location (const)

Neuron& icl::math::SOM::getNeuron ( const std::vector< int > &  dims)

returns a neuron at given grid location

const std::vector<Neuron>& icl::math::SOM::getNeurons ( ) const

returns the neuron set (const)

returns the neuron set

unsigned int icl::math::SOM::getSomDim ( ) const [inline]

returns the SOM dimension (e.g. 2D, 3D ..)

const Neuron& icl::math::SOM::getWinner ( const float *  input) const

returns a reference of the winner neuron dependent on a given input vector (const)

Neuron& icl::math::SOM::getWinner ( const float *  input)

returns a reference of the winner neuron dependent on a given input vector

void icl::math::SOM::setEpsilon ( float  epsilon)

sets the current learning rate epsilon

void icl::math::SOM::setSigma ( float  sigma)

sets the current grid distance function standard deviation

void icl::math::SOM::train ( const float *  input)

trains the net using given input vector and current parameters epsilon and sigma


Member Data Documentation

float icl::math::SOM::m_fEpsilon [protected]

learning rate

float icl::math::SOM::m_fSigma [protected]

standard deviation for the grid distance function

unsigned int icl::math::SOM::m_uiDataDim [protected]

internal data dimension variable

unsigned int icl::math::SOM::m_uiSomDim [protected]

internal SOM dimension variable ( = m_vecPrototypeBounds.size() = m_vecDimensions.size() )

std::vector<unsigned int> icl::math::SOM::m_vecDimensions [protected]

internal grid dimensions

std::vector<unsigned int> icl::math::SOM::m_vecDimOffsets [protected]

internal utility offset vector for each dimension

std::vector<Neuron> icl::math::SOM::m_vecNeurons [protected]

set of neurons

std::vector<utils::Range<float> > icl::math::SOM::m_vecPrototypeBounds [protected]

internal bounds for prototype ranges (todo: is it necessary to store them ?)


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines