Image Component Library (ICL)
Classes | Public Member Functions | Protected Attributes | List of all members
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

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

Protected Attributes

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

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

Grid distance function ( $h$)

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

Constructor & Destructor Documentation

◆ SOM()

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)$

◆ ~SOM()

icl::math::SOM::~SOM ( )

Destructor.

Member Function Documentation

◆ getDataDim()

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

returns the data dimension

◆ getDimensions()

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

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

◆ getNeuron() [1/2]

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

returns a neuron at given grid location (const)

◆ getNeuron() [2/2]

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

returns a neuron at given grid location

◆ getNeurons() [1/2]

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

returns the neuron set (const)

◆ getNeurons() [2/2]

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

returns the neuron set

◆ getSomDim()

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

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

◆ getWinner() [1/2]

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

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

◆ getWinner() [2/2]

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

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

◆ setEpsilon()

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

sets the current learning rate epsilon

◆ setSigma()

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

sets the current grid distance function standard deviation

◆ train()

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

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

Member Data Documentation

◆ m_fEpsilon

float icl::math::SOM::m_fEpsilon
protected

learning rate

◆ m_fSigma

float icl::math::SOM::m_fSigma
protected

standard deviation for the grid distance function

◆ m_uiDataDim

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

internal data dimension variable

◆ m_uiSomDim

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

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

◆ m_vecDimensions

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

internal grid dimensions

◆ m_vecDimOffsets

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

internal utility offset vector for each dimension

◆ m_vecNeurons

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

set of neurons

◆ m_vecPrototypeBounds

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: