Image Component Library (ICL)
|
Generic implementation of D to K dim Self Organizing Map (SOM) More...
#include <SOM.h>
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 Neuron & | getWinner (const float *input) const |
returns a reference of the winner neuron dependent on a given input vector (const) | |
Neuron & | getWinner (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 Neuron & | getNeuron (const std::vector< int > &dims) const |
returns a neuron at given grid location (const) | |
Neuron & | getNeuron (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< Neuron > | m_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 |
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"
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.
dataDim | dimension of data elements and prototype vectors |
dims | grid 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 . |
prototypeBounds | Internals 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 , prototypeBounds must be (where the ranges are written as tuples). |
epsilon | initial learning rate |
sigma | initial standard deviation for the grid distance function |
Destructor.
unsigned int icl::math::SOM::getDataDim | ( | ) | const [inline] |
returns the data dimension
const std::vector<unsigned int> icl::math::SOM::getDimensions | ( | ) | const [inline] |
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)
std::vector<Neuron>& icl::math::SOM::getNeurons | ( | ) |
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
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 ?)