GPUMLib  0.2.2
GPU Machine Learning Library
RadialBasisFunction.h
1 /*
2  Ricardo Quintas is an MSc Student at the University of Coimbra, Portugal
3  Copyright (C) 2009, 2010 Ricardo Quintas
4 
5  This file is part of GPUMLib.
6 
7  GPUMLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef RadialBasisFunction_h
22 #define RadialBasisFunction_h
23 
24 #include <stdio.h>
25 #include <string.h>
26 #include <vector>
27 #include <algorithm>
28 
29 #include "../common/CudaDefinitions.h"
30 #include "../memory/HostMatrix.h"
31 #include "../memory/DeviceMatrix.h"
32 
33 #include "../RBF/utils.h"
34 #include "../RBF/rbfkernels.h"
35 
36 #include "../KMeans/KMeans.h"
37 
38 #include <ctime>
39 
40 #define imin(X, Y) ((X) < (Y) ? (X) : (Y))
41 #define imax(X, Y) ((X) > (Y) ? (X) : (Y))
42 #define round(x) (x<0?ceil((x)-0.5):floor((x)+0.5))
43 
44 using namespace std;
45 
46 namespace GPUMLib {
47 
50 
53 
54 private:
55 
56  int network_size;
57  int number_neighbours;
58 
59  //HostMatrix<float> Weights;
60  //HostMatrix<float> Centers;
61 
62  DeviceMatrix<float> dWeights;
63  DeviceMatrix<float> dCenters;
64 
65  DeviceArray<float> device_c_width;
66 
67  //float *c_width;
68  float scaling_factor;
69 
70  int NumClasses;
71 
72  unsigned int seed;
73 
74 public:
75 
76 
77 
78  unsigned int start;
79  unsigned int times[4];
80 
86  RadialBasisFunction(int network_size, int number_neighbours, float scaling_factor, int NumClasses);
87 
89 
93  void Train(HostMatrix<float> &Input,HostMatrix<float> &Target);
94 
95 
100 
105 
113 
116  void AdjustWidths(int rneighbours);
117 
120  void SetScalingFactor(float scaling_factor){
121  this->scaling_factor = scaling_factor;
122  }
123 
127  return scaling_factor;
128  }
129 
130  void SetSeed(unsigned int seed){
131  this->seed = seed;
132  }
133 
134  unsigned int GetSeed(){
135  return seed;
136  }
137 
141  return dWeights;
142  }
143 
147  return dCenters;
148  }
149 
153  return device_c_width;
154  }
155 };
156 
159 
161 
162 }
163 
164 #endif
Represents a radial basis function network that can be trained using the CUDA implementation of the R...
DeviceMatrix< float > GetCenters()
DeviceArray< float > & GetWidths()
DeviceMatrix< float > GetWeights()
void SetScalingFactor(float scaling_factor)