21 #ifndef SELF_ORGANISING_MAP_H
22 #define SELF_ORGANISING_MAP_H
23 #define MAX_GPU_DEVICES 4
27 #include <cuda_runtime.h>
32 class SOM :
public yarp::os::Thread
41 string trainingFileName;
73 int neighbourhoodSize;
74 int currentNeighbourhoodSize;
77 float highestDataPoint;
78 float lowestDataPoint;
79 float initLearningRate;
82 bool visualiseProgress;
86 void allocateMemory();
88 void updateProgress();
89 void findBestMatch(
float *outputs,
int *winner,
int numOutputs);
90 void propogateInput(
float *inputs,
float *weights,
float *outputs,
int numInputs,
int sequenceId,
int numOutputs);
91 void updateWeights(
float *inputs,
float *weights,
int *winner,
float sigma,
int numInputs,
int sequenceId,
int numOutputs,
int neighbourhoodSize,
float initLearningRate,
int numIterations,
int currentIteration);
92 float scaleRange(
float in,
float oldMin,
float oldMax,
float newMin,
float newMax);
95 vector<string> queryGPU();
96 void loadTrainingSet(Bottle portData = 0);
97 void randomiseWeights();
100 void printGPUProperties(
int deviceID);
102 void setGPUMode(
bool gpuMode);
103 void setDebugMessages(
int level);
104 void setDevice(
int device);
105 void setSeed(
int value);
106 void setMaxThreads(
int threads);
107 void setNumInputs(
int inputs);
108 void setNumSamples(
int samples);
109 void setNumOutputs(
int outputs);
110 void setNumSubiterations(
int subIterations);
111 void setInitLearningRate(
float learningRate);
112 void setSigma(
float sigma);
113 void setVisualiseProgress(
bool visualise);
114 void setIterationPause(
int value);
115 void setNeighbourhoodSize(
int value);
116 void setNumIterations(
int value);
117 void setTrainingFile(
string fileName);
118 void setMapFile(
string fileName);
120 void getWeightsAsBottle(Bottle *bottle);
122 int getDebugMessages();
128 int getNeighbourhoodSize();
129 int getNumSubiterations();
130 int getIterationPause();
131 float getInitLearningRate();
133 float getTrainingTime();
134 float getLowestDataPoint();
135 float getHighestDataPoint();
136 bool getVisualiseProgress();
137 string getTrainingFile();
143 void propogateInputOnDevice(dim3 grid, dim3 block,
float *inputs,
float *weights,
float *outputs,
int numInputs,
int sequenceId,
int numOutputs);
144 void updateWeightsOnDevice(dim3 grid, dim3 block,
float *inputs,
float *weights,
int *winner,
float sigma,
int numInputs,
int sequenceId,
int numOutputs,
int neighbourhoodSize,
float initLearningRate,
int numIterations,
int currentIteration);
146 #endif//SELF_ORGANISING_MAP_H