mlpack 3.4.2
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
18namespace mlpack {
19namespace ann {
20
30template <
31 typename InputDataType = arma::mat,
32 typename OutputDataType = arma::mat
33>
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
85 template<typename Archive>
86 void serialize(Archive& ar, const unsigned int /* version */);
87
88 private:
90 size_t inSize;
91
93 size_t outSize;
94
96 OutputDataType constantOutput;
97
99 OutputDataType delta;
100
102 OutputDataType outputParameter;
103}; // class ConstantLayer
104
105} // namespace ann
106} // namespace mlpack
107
108// Include implementation.
109#include "constant_impl.hpp"
110
111#endif
Implementation of the constant layer.
Definition: constant.hpp:35
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network.
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.
size_t OutSize() const
Get the output size.
Definition: constant.hpp:80
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: constant.hpp:70
OutputDataType & Delta() const
Get the delta.
Definition: constant.hpp:75
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: constant.hpp:72
void Backward(const DataType &, const DataType &, DataType &g)
Ordinary feed backward pass of a neural network.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Definition: constant.hpp:77
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.