STATUS: experimental Self-Organizing Maps More...
#include "definitions.h"
#include "helper.h"
#include "distances.h"
Go to the source code of this file.
Data Structures | |
struct | Som |
1-dimensional SOM with trivial topology (neighbouring nodes). More... | |
Typedefs | |
typedef double(* | NeighbourhoodFunction )(int, int, struct som_struct *, int t) |
typedef double(* | TimeDecayFunction )(int, int, int) |
alpha = f( t, nruns, nruns in initial_phase ) | |
Enumerations | |
enum | SOMConnectivityType { ONED_LINEAR, TWOD_GRID, TWOD_HEXAGONAL, CUSTOM } |
defines the dimension/structure of the SOM. More... | |
Functions | |
void | som_free (Som *s) |
double ** | som_generate_connectivity_matrix (SOMConnectivityType type, double **m, int n) |
Som * | som_init (int dimension, int n, int nruns, SOMConnectivityType connectivity) |
void | som_initialize_random (Som *s, double min, double max) |
void | som_initialize_random_samples (Som *s, double **X, int dim, int nsamples) |
double | som_neighbourhood_gaussian (int x, int bmu, struct som_struct *s, int t) |
void | som_print (FILE *f, Som *s) |
double | som_time_decay_linear (int t, int nruns, int initial_runs) |
void | som_train_from_data (Som *s, double **X, int dim, int nsamples) |
STATUS: experimental Self-Organizing Maps
Self-Organizing Feature Maps are extensively described in
Kohonen, T. 1995. Self-Organizing Maps. Springer.
We have a set of n neurons that are of dimension m:. The neurons are arranged on a bidirectional, connected graph, such that there exists a distance between two neurons.
Using input data, of dimension m, we find the best-matching unit (BMU)
(we can use any other metric as well - many metrices are implemented in LibEEGTools).
Then, we update each neuron by the learning rule
where is a time-decaying function, h(t) is a neighbourhood function centered on the BMU (e.g. gaussian) which narrows down with increasing time.
In this implementation, we divide the training phase into an initial and a fine-tuning phase. During the initial phase, $$ takes on rather large values and the neighbourhood is wide such that an initial arrangement may take place. Later, both parameters are narrowed down to enable fine-tuning.
All of the parameters can be conveniently manipulated in the implementation.
The implementation given here is quite general but not very efficient. Topology of the network of neurons is implemented in terms of distance matrices between two neurons (in terms of their ''physical'' distance D on the graph).
The user can either supply this matrix directly or generate such a matrix using our convenience function som_generate_connectivity_matrix().
First, you need to initialize a Som-struct using som_init(). You need to supply a value of SOMConnectivityType. If it is not CUSTOM, the function will allocate a connectivity matrix.
Som *S; S = som_init( 2, 1000, 1e6, ONED_LINEAR );
Definition in file som.h.
typedef double(* NeighbourhoodFunction)(int, int, struct som_struct *, int t) |
typedef double(* TimeDecayFunction)(int, int, int) |
enum SOMConnectivityType |
defines the dimension/structure of the SOM.
double** som_generate_connectivity_matrix | ( | SOMConnectivityType | type, | |
double ** | m, | |||
int | n | |||
) |
generate a connectivity matrix of type type. The (i,j)th entry gives the distance between nodes i and j in number of nodes.
type:
type | ||
m | if NULL or ALLOC_IN_FCT, allocate own memory. | |
n | number of nodes |
Som* som_init | ( | int | dimension, | |
int | n, | |||
int | nruns, | |||
SOMConnectivityType | connectivity_type | |||
) |
void som_initialize_random | ( | Som * | s, | |
double | min, | |||
double | max | |||
) |
void som_initialize_random_samples | ( | Som * | s, | |
double ** | X, | |||
int | dim, | |||
int | nsamples | |||
) |
double som_neighbourhood_gaussian | ( | int | x, | |
int | bmu, | |||
struct som_struct * | s, | |||
int | t | |||
) |
double som_time_decay_linear | ( | int | t, | |
int | nruns, | |||
int | initial_runs | |||
) |