mlpack 3.4.2
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
18namespace mlpack {
19namespace ann {
20
30template <
31 typename InputDataType = arma::mat,
32 typename OutputDataType = arma::mat
33>
35{
36 public:
40 MultiplyConstant(const double scalar = 1.0);
41
49 template<typename InputType, typename OutputType>
50 void Forward(const InputType& input, OutputType& output);
51
60 template<typename DataType>
61 void Backward(const DataType& /* input */, const DataType& gy, DataType& g);
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
74 double Scalar() const { return scalar; }
76 double& Scalar() { return scalar; }
77
81 template<typename Archive>
82 void serialize(Archive& ar, const unsigned int /* version */);
83
84 private:
86 double scalar;
87
89 OutputDataType delta;
90
92 OutputDataType outputParameter;
93}; // class MultiplyConstant
94
95} // namespace ann
96} // namespace mlpack
97
98// Include implementation.
99#include "multiply_constant_impl.hpp"
100
101#endif
Implementation of the multiply constant layer.
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network.
OutputDataType & OutputParameter() const
Get the output parameter.
void Backward(const DataType &, const DataType &gy, DataType &g)
Ordinary feed backward pass of a neural network.
OutputDataType & Delta() const
Get the delta.
double Scalar() const
Get the scalar multiplier.
MultiplyConstant(const double scalar=1.0)
Create the MultiplyConstant object.
double & Scalar()
Modify the scalar multiplier.
OutputDataType & OutputParameter()
Modify the output parameter.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.