mlpack  master
multiply_constant.hpp
Go to the documentation of this file.
1 
8 #ifndef MLPACK_METHODS_ANN_LAYER_MULTIPLY_CONSTANT_HPP
9 #define MLPACK_METHODS_ANN_LAYER_MULTIPLY_CONSTANT_HPP
10 
11 #include <mlpack/prereqs.hpp>
12 
13 namespace mlpack {
14 namespace ann {
15 
25 template <
26  typename InputDataType = arma::mat,
27  typename OutputDataType = arma::mat
28 >
30 {
31  public:
35  MultiplyConstant(const double scalar);
36 
44  template<typename InputType, typename OutputType>
45  void Forward(const InputType&& input, OutputType&& output);
46 
55  template<typename DataType>
56  void Backward(const DataType&& /* input */, DataType&& gy, DataType&& g);
57 
59  InputDataType& InputParameter() const { return inputParameter; }
61  InputDataType& InputParameter() { return inputParameter; }
62 
64  OutputDataType& OutputParameter() const { return outputParameter; }
66  OutputDataType& OutputParameter() { return outputParameter; }
67 
69  OutputDataType& Delta() const { return delta; }
71  OutputDataType& Delta() { return delta; }
72 
76  template<typename Archive>
77  void Serialize(Archive& ar, const unsigned int /* version */);
78 
79  private:
81  const double scalar;
82 
84  OutputDataType delta;
85 
87  InputDataType inputParameter;
88 
90  OutputDataType outputParameter;
91 }; // class MultiplyConstant
92 
93 } // namespace ann
94 } // namespace mlpack
95 
96 // Include implementation.
97 #include "multiply_constant_impl.hpp"
98 
99 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
InputDataType & InputParameter()
Modify the input parameter.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter() const
Get the output parameter.
OutputDataType & Delta()
Modify the delta.
OutputDataType & OutputParameter()
Modify the output parameter.
MultiplyConstant(const double scalar)
Create the MultiplyConstant object.
void Forward(const InputType &&input, OutputType &&output)
Ordinary feed forward pass of a neural network.
OutputDataType delta
Locally-stored delta object.
InputDataType & InputParameter() const
Get the input parameter.
void Serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType outputParameter
Locally-stored output parameter object.
Implementation of the multiply constant layer.
InputDataType inputParameter
Locally-stored input parameter object.
const double scalar
Locally-stored constant scalar value.
OutputDataType & Delta() const
Get the delta.
void Backward(const DataType &&, DataType &&gy, DataType &&g)
Ordinary feed backward pass of a neural network.