| 1 |
2 |
bertin |
/*
|
| 2 |
|
|
som.h
|
| 3 |
|
|
|
| 4 |
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 5 |
|
|
*
|
| 6 |
|
|
* Part of: A program using neural networks.
|
| 7 |
|
|
*
|
| 8 |
|
|
* Author: E.BERTIN, IAP & Leiden observatory.
|
| 9 |
|
|
*
|
| 10 |
|
|
* Contents: Include for Kohonen's Self Organizing Map (V2.0).
|
| 11 |
|
|
*
|
| 12 |
|
|
* Last modify: 17/12/97
|
| 13 |
|
|
*
|
| 14 |
|
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 15 |
|
|
*/
|
| 16 |
|
|
|
| 17 |
|
|
/*--------------------------------- constants ------------------------------*/
|
| 18 |
|
|
|
| 19 |
|
|
#define INPUT_MAXDIM 9 /* Maximum dimensionality of input */
|
| 20 |
|
|
#define SOM_MAXDIM 6 /* Maximum dimensionality of the SOM */
|
| 21 |
|
|
|
| 22 |
|
|
/*------------------------------- SOM flags --------------------------------*/
|
| 23 |
|
|
|
| 24 |
|
|
#define SOM_NODE 0x01 /* Compute at some exact node pos */
|
| 25 |
|
|
#define SOM_PHOTOM 0x02 /* Do photometry */
|
| 26 |
|
|
#define SOM_GRADIENT 0x04 /* Compute interpolated SOM gradient */
|
| 27 |
|
|
#define SOM_LINE 0x08 /* Proceed along a specific line */
|
| 28 |
|
|
|
| 29 |
|
|
/*--------------------------- structure definitions -------------------------*/
|
| 30 |
|
|
|
| 31 |
|
|
typedef struct
|
| 32 |
|
|
{
|
| 33 |
|
|
int inputdim; /* Dimensionality of input vector */
|
| 34 |
|
|
int *inputsize; /* Dimensions of the input vector */
|
| 35 |
|
|
int ninput; /* Total number of inputs */
|
| 36 |
|
|
int nextrainput; /* Number of extra inputs */
|
| 37 |
|
|
int neurdim; /* Dimensionality of the SOM */
|
| 38 |
|
|
int *neursize; /* Dimensions of the SOM */
|
| 39 |
|
|
int nneur; /* Total number of neurons */
|
| 40 |
|
|
int *neurstep; /* Stepping through the SOM */
|
| 41 |
|
|
float *weight; /* Weights */
|
| 42 |
|
|
int nweight; /* Total number of weights */
|
| 43 |
|
|
float *input; /* Input data */
|
| 44 |
|
|
float *inputw; /* Input data weighting */
|
| 45 |
|
|
float *proto; /* Current composite prototype */
|
| 46 |
|
|
float *dproto; /* Current composite gradients */
|
| 47 |
|
|
float *vector; /* Current SOM coordinates */
|
| 48 |
|
|
float *dvector; /* Current SOM search direction */
|
| 49 |
|
|
float learnrate, clearnrate; /* Starting and current learn. rates */
|
| 50 |
|
|
float learndecay; /* Learning decay rate */
|
| 51 |
|
|
float kernw, ckernw; /* Starting and current kernel width */
|
| 52 |
|
|
float kernwdecay; /* Kernel width decay rate */
|
| 53 |
|
|
float xy_stiff; /* Stiffness of the X/Y mapping */
|
| 54 |
|
|
int *freq; /* Number of winning times per node */
|
| 55 |
|
|
int ntrain; /* # of training examples so far */
|
| 56 |
|
|
int nsweep; /* # of sweeps through the whole set */
|
| 57 |
|
|
float amp, sigamp; /* Best fitting amplitude and error */
|
| 58 |
|
|
float stderror; /* Global reduced error */
|
| 59 |
|
|
} somstruct;
|
| 60 |
|
|
|
| 61 |
|
|
somstruct *thesom;
|
| 62 |
|
|
|
| 63 |
|
|
/*---------------------------------- protos --------------------------------*/
|
| 64 |
|
|
|
| 65 |
|
|
extern somstruct *som_load(char *filename);
|
| 66 |
|
|
|
| 67 |
|
|
extern float som_err(somstruct *som, float dist, int flag),
|
| 68 |
|
|
som_linmin(somstruct *som);
|
| 69 |
|
|
|
| 70 |
|
|
extern int som_mkweight(somstruct *som,float back,float backnoise,
|
| 71 |
|
|
float gain);
|
| 72 |
|
|
|
| 73 |
|
|
extern void som_conjgrad(somstruct *som, float ftol),
|
| 74 |
|
|
som_end(somstruct *som),
|
| 75 |
|
|
som_phot(somstruct *som, float back,float backnoise,
|
| 76 |
|
|
float gain, float dx, float dy,
|
| 77 |
|
|
float *vector, float clip),
|
| 78 |
|
|
som_start(somstruct *som, float *context,
|
| 79 |
|
|
int ncontext, float x, float y);
|