Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
Som< T > Class Template Reference

#include <Som.h>

Public Member Functions

 Som (int width=0, int height=0)
 
void setGeometry (int width, int height)
 
void fill (const T &sample)
 
void initialise (void(*init)(T &x))
 Initialise the map with a user-defined function. More...
 
void setNeighbourhoodRadius (double r)
 
void setLearningCoefficient (double c)
 
void setDistanceFunction (double(*d)(const T &x1, const T &x2))
 
void setMixingFunction (void(*mix)(const T &x1, const T &x2, double coeff, T &m))
 
int getHeight () const
 The number of rows in the map.
 
int getWidth () const
 The number of columns in the map.
 
void findBestMatchingUnit (const T &sample, int &iBest, int &jBest)
 Finds the unit with state closesest to that of sample. More...
 
void train (const T &x)
 Training with a single sample. More...
 
void train (const T &x, int iBest, int jBest)
 
void toStream (std::ostream &ostr) const
 
double defaultNeighborhoodFunction (const int &i, const int &j) const
 
 Som (int width, int height)
 

Static Public Member Functions

static double defaultDistanceMetric (const T &x1, const T &x2)
 
static void defaultMixingFunction (const T &x1, const T &x2, double coeff, T &m)
 

Public Attributes

std::vector< std::vector< T > > map
 The actual neural network, two-dimensional map of units.
 

Protected Attributes

double(* distanceFunction )(const T &x1, const T &x2)
 The similarity metric applied in finding the best-matching unit.
 
void(* mixingFunction )(const T &x1, const T &x2, double alpha, T &result)
 Given objects x1 and x1 and a mixing coefficient coeff , outputs mixed object m. More...
 
std::string title
 
int width
 
int height
 
double radius2
 The radius of the neighbourhood kernel applied in training;.
 
double learningCoefficient
 The radius of the neighbourhood kernel applied in training;.
 

Detailed Description

template<class T = std::vector<double>>
class drain::Som< T >

The Self-Organising Map by Teuvo Kohonen.

The template

The coordinates of the map apply matrix convention ie. map[i][j] refers to element j on row i. The map is implemented a std::vector<std::vector<T> > .

Member Function Documentation

◆ fill()

void fill ( const T &  sample)
inline

Set each neuron in the map to given value.

◆ findBestMatchingUnit()

void findBestMatchingUnit ( const T &  sample,
int &  iBest,
int &  jBest 
)
inline

Finds the unit with state closesest to that of sample.

sample - the state against which the similarity of unit states is compared.
i - the row of the best matching unit
j - the column of the best matching unit

◆ initialise()

void initialise ( void(*)(T &x)  init)
inline

Initialise the map with a user-defined function.

The user defined function with signature

void (* init)(T & x)

should initialize

◆ setGeometry()

void setGeometry ( int  width,
int  height 
)
inline
Parameters
heightthe height recipient set

◆ train() [1/2]

void train ( const T &  x)
inline

Training with a single sample.

Calls findBestMatchingUnit() and uses *mixingFunction to tune the unit.

◆ train() [2/2]

void train ( const T &  x,
int  iBest,
int  jBest 
)
inline

Training with a single sample.

Member Data Documentation

◆ mixingFunction

void(* mixingFunction) (const T &x1, const T &x2, double alpha, T &result)
protected

Given objects x1 and x1 and a mixing coefficient coeff , outputs mixed object m.

One might think of mixing two std::strings, for example.


The documentation for this class was generated from the following file: