mlpack 3.4.2
noisylinear.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_METHODS_ANN_LAYER_NOISYLINEAR_HPP
13#define MLPACK_METHODS_ANN_LAYER_NOISYLINEAR_HPP
14
15#include <mlpack/prereqs.hpp>
16
17namespace mlpack {
18namespace ann {
19
29template <
30 typename InputDataType = arma::mat,
31 typename OutputDataType = arma::mat
32>
34{
35 public:
38
45 NoisyLinear(const size_t inSize,
46 const size_t outSize);
47
50
51 /*
52 * Reset the layer parameter.
53 */
54 void Reset();
55
56 /*
57 * Reset the noise parameters(epsilons).
58 */
59 void ResetNoise();
60
61 /*
62 * Reset the values of layer parameters (factorized gaussian noise).
63 */
65
73 template<typename eT>
74 void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
75
85 template<typename eT>
86 void Backward(const arma::Mat<eT>& /* input */,
87 const arma::Mat<eT>& gy,
88 arma::Mat<eT>& g);
89
90 /*
91 * Calculate the gradient using the output delta and the input activation.
92 *
93 * @param input The input parameter used for calculating the gradient.
94 * @param error The calculated error.
95 * @param gradient The calculated gradient.
96 */
97 template<typename eT>
98 void Gradient(const arma::Mat<eT>& input,
99 const arma::Mat<eT>& error,
100 arma::Mat<eT>& gradient);
101
103 OutputDataType const& Parameters() const { return weights; }
105 OutputDataType& Parameters() { return weights; }
106
108 InputDataType const& InputParameter() const { return inputParameter; }
110 InputDataType& InputParameter() { return inputParameter; }
111
113 OutputDataType const& OutputParameter() const { return outputParameter; }
115 OutputDataType& OutputParameter() { return outputParameter; }
116
118 OutputDataType const& Delta() const { return delta; }
120 OutputDataType& Delta() { return delta; }
121
123 size_t InputSize() const { return inSize; }
124
126 size_t OutputSize() const { return outSize; }
127
129 OutputDataType const& Gradient() const { return gradient; }
131 OutputDataType& Gradient() { return gradient; }
132
134 arma::mat& Bias() { return bias; }
135
139 template<typename Archive>
140 void serialize(Archive& ar, const unsigned int /* version */);
141
142 private:
144 size_t inSize;
145
147 size_t outSize;
148
150 OutputDataType weights;
151
153 OutputDataType weight;
154
156 OutputDataType weightMu;
157
159 OutputDataType weightSigma;
160
162 OutputDataType weightEpsilon;
163
165 OutputDataType bias;
166
168 OutputDataType biasMu;
169
171 OutputDataType biasSigma;
172
174 OutputDataType biasEpsilon;
175
177 OutputDataType delta;
178
180 OutputDataType gradient;
181
183 InputDataType inputParameter;
184
186 OutputDataType outputParameter;
187}; // class NoisyLinear
188
189} // namespace ann
190} // namespace mlpack
191
192// Include implementation.
193#include "noisylinear_impl.hpp"
194
195#endif
Implementation of the NoisyLinear layer class.
Definition: noisylinear.hpp:34
OutputDataType const & Delta() const
Get the delta.
OutputDataType const & Parameters() const
Get the parameters.
NoisyLinear(const NoisyLinear &)
Copy constructor.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
InputDataType & InputParameter()
Modify the input parameter.
NoisyLinear(const size_t inSize, const size_t outSize)
Create the NoisyLinear layer object using the specified number of units.
OutputDataType const & OutputParameter() const
Get the output parameter.
size_t InputSize() const
Get the input size.
NoisyLinear()
Create the NoisyLinear object.
size_t OutputSize() const
Get the output size.
void Gradient(const arma::Mat< eT > &input, const arma::Mat< eT > &error, arma::Mat< eT > &gradient)
OutputDataType const & Gradient() const
Get the gradient.
InputDataType const & InputParameter() const
Get the input parameter.
OutputDataType & Gradient()
Modify the gradient.
void Backward(const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...
OutputDataType & OutputParameter()
Modify the output parameter.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Parameters()
Modify the parameters.
arma::mat & Bias()
Modify the bias weights of 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.