constant.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LAYER_CONSTANT_HPP
14 #define MLPACK_METHODS_ANN_LAYER_CONSTANT_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace ann {
20 
30 template <
31  typename InputDataType = arma::mat,
32  typename OutputDataType = arma::mat
33 >
34 class Constant
35 {
36  public:
44  Constant(const size_t outSize = 0, const double scalar = 0.0);
45 
53  template<typename InputType, typename OutputType>
54  void Forward(const InputType& input, OutputType& output);
55 
64  template<typename DataType>
65  void Backward(const DataType& /* input */,
66  const DataType& /* gy */,
67  DataType& g);
68 
70  OutputDataType& OutputParameter() const { return outputParameter; }
72  OutputDataType& OutputParameter() { return outputParameter; }
73 
75  OutputDataType& Delta() const { return delta; }
77  OutputDataType& Delta() { return delta; }
78 
80  size_t OutSize() const { return outSize; }
81 
83  size_t WeightSize() const
84  {
85  return 0;
86  }
87 
91  template<typename Archive>
92  void serialize(Archive& ar, const uint32_t /* version */);
93 
94  private:
96  size_t inSize;
97 
99  size_t outSize;
100 
102  OutputDataType constantOutput;
103 
105  OutputDataType delta;
106 
108  OutputDataType outputParameter;
109 }; // class ConstantLayer
110 
111 } // namespace ann
112 } // namespace mlpack
113 
114 // Include implementation.
115 #include "constant_impl.hpp"
116 
117 #endif
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: constant.hpp:72
Linear algebra utility functions, generally performed on matrices or vectors.
Constant(const size_t outSize=0, const double scalar=0.0)
Create the Constant object that outputs a given constant scalar value given any input value...
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t OutSize() const
Get the output size.
Definition: constant.hpp:80
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: constant.hpp:70
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network.
OutputDataType & Delta()
Modify the delta.
Definition: constant.hpp:77
OutputDataType & Delta() const
Get the delta.
Definition: constant.hpp:75
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
size_t WeightSize() const
Get the size of the weights.
Definition: constant.hpp:83
Implementation of the constant layer.
Definition: constant.hpp:34
void Backward(const DataType &, const DataType &, DataType &g)
Ordinary feed backward pass of a neural network.