radial_basis_function.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LAYER_RBF_HPP
14 #define MLPACK_METHODS_ANN_LAYER_RBF_HPP
15 
16 #include <mlpack/prereqs.hpp>
18 
19 #include "layer_types.hpp"
20 
21 namespace mlpack {
22 namespace ann {
23 
24 
48 template <
49  typename InputDataType = arma::mat,
50  typename OutputDataType = arma::mat,
51  typename Activation = GaussianFunction
52 >
53 class RBF
54 {
55  public:
57  RBF();
58 
68  RBF(const size_t inSize,
69  const size_t outSize,
70  arma::mat& centres,
71  double betas = 0);
72 
79  template<typename eT>
80  void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
81 
86  template<typename eT>
87  void Backward(const arma::Mat<eT>& /* input */,
88  const arma::Mat<eT>& /* gy */,
89  arma::Mat<eT>& /* g */);
90 
92  OutputDataType const& OutputParameter() const { return outputParameter; }
94  OutputDataType& OutputParameter() { return outputParameter; }
96 
98  InputDataType const& InputParameter() const { return inputParameter; }
100  InputDataType& InputParameter() { return inputParameter; }
101 
103  size_t InputSize() const { return inSize; }
104 
106  size_t OutputSize() const { return outSize; }
107 
109  OutputDataType const& Delta() const { return delta; }
111  OutputDataType& Delta() { return delta; }
112 
114  size_t WeightSize() const
115  {
116  return 0;
117  }
118 
120  size_t InputShape() const
121  {
122  return inSize;
123  }
124 
128  template<typename Archive>
129  void serialize(Archive& ar, const uint32_t /* version */);
130 
131  private:
133  size_t inSize;
134 
136  size_t outSize;
137 
139  OutputDataType delta;
140 
142  OutputDataType outputParameter;
143 
145  double sigmas;
146 
148  double betas;
149 
151  InputDataType centres;
152 
154  InputDataType inputParameter;
155 
157  OutputDataType distances;
158 }; // class RBF
159 
160 } // namespace ann
161 } // namespace mlpack
162 
163 // Include implementation.
164 #include "radial_basis_function_impl.hpp"
165 
166 #endif
OutputDataType const & OutputParameter() const
Get the output parameter.
size_t WeightSize() const
Get the size of the weights.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & Delta() const
Get the detla.
InputDataType & InputParameter()
Modify the input parameter.
OutputDataType & OutputParameter()
Modify the output parameter.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
InputDataType const & InputParameter() const
Get the parameters.
RBF()
Create the RBF object.
size_t InputShape() const
Get the shape of the input.
void Backward(const arma::Mat< eT > &, const arma::Mat< eT > &, arma::Mat< eT > &)
Ordinary feed backward pass of the radial basis function.
size_t OutputSize() const
Get the output size.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of the radial basis function.
size_t InputSize() const
Get the input size.
OutputDataType & Delta()
Modify the delta.