GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
SoftmaxModel.h
Go to the documentation of this file.
1 
29 #ifndef GRT_SOFTMAX_MODEL_HEADER
30 #define GRT_SOFTMAX_MODEL_HEADER
31 
32 #include "../../CoreModules/Classifier.h"
33 
34 namespace GRT{
35 
37 public:
38  SoftmaxModel(){
39  classLabel = 0;
40  N = 0;
41  }
42  ~SoftmaxModel(){
43 
44  }
45 
46  bool init(UINT classLabel,UINT N){
47  this->classLabel = classLabel;
48  this->N = N;
49 
50  //Resize the weights
51  w.clear();
52  w.resize(N);
53 
54  //Randomize the weights
55  Random rand;
56  for(UINT i=0; i<N; i++){
57  w[i] = rand.getRandomNumberUniform(-0.1,0.1);
58  }
59  w0 = rand.getRandomNumberUniform(-0.1,0.1);
60 
61  return true;
62  }
63 
64  double compute(const VectorDouble &x){
65  double sum = w0;
66  for(UINT i=0; i<N; i++){
67  sum += x[i]*w[i];
68  }
69  return (1.0 / (1.0+exp(-sum)));
70  }
71 
72  UINT classLabel;
73  UINT N; //The number of dimensions
74  VectorDouble w; //The coefficents
75  double w0;
76 
77 };
78 
79 } //End of namespace GRT
80 
81 #endif //SoftmaxModel
82 
Definition: AdaBoost.cpp:25
double getRandomNumberUniform(double minRange=0.0, double maxRange=1.0)
Definition: Random.h:197