multiply_constant.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LAYER_MULTIPLY_CONSTANT_HPP
14 #define MLPACK_METHODS_ANN_LAYER_MULTIPLY_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 >
35 {
36  public:
40  MultiplyConstant(const double scalar = 1.0);
41 
43  MultiplyConstant(const MultiplyConstant& layer);
44 
47 
50 
53 
61  template<typename InputType, typename OutputType>
62  void Forward(const InputType& input, OutputType& output);
63 
72  template<typename DataType>
73  void Backward(const DataType& /* input */, const DataType& gy, DataType& g);
74 
76  OutputDataType& OutputParameter() const { return outputParameter; }
78  OutputDataType& OutputParameter() { return outputParameter; }
79 
81  OutputDataType& Delta() const { return delta; }
83  OutputDataType& Delta() { return delta; }
84 
86  double Scalar() const { return scalar; }
88  double& Scalar() { return scalar; }
89 
91  size_t WeightSize() const { return 0; }
92 
96  template<typename Archive>
97  void serialize(Archive& ar, const uint32_t /* version */);
98 
99  private:
101  double scalar;
102 
104  OutputDataType delta;
105 
107  OutputDataType outputParameter;
108 }; // class MultiplyConstant
109 
110 } // namespace ann
111 } // namespace mlpack
112 
113 // Include implementation.
114 #include "multiply_constant_impl.hpp"
115 
116 #endif
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network.
size_t WeightSize() const
Get the size of the weights.
OutputDataType & OutputParameter()
Modify the output parameter.
Linear algebra utility functions, generally performed on matrices or vectors.
OutputDataType & Delta()
Modify the delta.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
void Backward(const DataType &, const DataType &gy, DataType &g)
Ordinary feed backward pass of a neural network.
double & Scalar()
Modify the scalar multiplier.
OutputDataType & OutputParameter() const
Get the output parameter.
MultiplyConstant & operator=(const MultiplyConstant &layer)
Copy assignment operator.
double Scalar() const
Get the scalar multiplier.
OutputDataType & Delta() const
Get the delta.
MultiplyConstant(const double scalar=1.0)
Create the MultiplyConstant object.
Implementation of the multiply constant layer.