mlpack 3.4.2
alpha_dropout.hpp
Go to the documentation of this file.
1
16#ifndef MLPACK_METHODS_ANN_LAYER_ALPHA_DROPOUT_HPP
17#define MLPACK_METHODS_ANN_LAYER_ALPHA_DROPOUT_HPP
18
19#include <mlpack/prereqs.hpp>
20
21namespace mlpack {
22namespace ann {
23
48template <typename InputDataType = arma::mat,
49 typename OutputDataType = arma::mat>
51{
52 public:
59 AlphaDropout(const double ratio = 0.5,
60 const double alphaDash = -alpha * lambda);
61
68 template<typename eT>
69 void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
70
78 template<typename eT>
79 void Backward(const arma::Mat<eT>& /* input */,
80 const arma::Mat<eT>& gy,
81 arma::Mat<eT>& g);
82
84 OutputDataType const& OutputParameter() const { return outputParameter; }
86 OutputDataType& OutputParameter() { return outputParameter; }
87
89 OutputDataType const& Delta() const { return delta; }
91 OutputDataType& Delta() { return delta; }
92
94 bool Deterministic() const { return deterministic; }
96 bool& Deterministic() { return deterministic; }
97
99 double Ratio() const { return ratio; }
100
102 double A() const { return a; }
103
105 double B() const { return b; }
106
108 double AlphaDash() const {return alphaDash; }
109
111 OutputDataType const& Mask() const {return mask;}
112
115 void Ratio(const double r)
116 {
117 ratio = r;
118 a = pow((1 - ratio) * (1 + ratio * pow(alphaDash, 2)), -0.5);
119 b = -a * alphaDash * ratio;
120 }
121
125 template<typename Archive>
126 void serialize(Archive& ar, const unsigned int /* version */);
127
128 private:
130 OutputDataType delta;
131
133 OutputDataType outputParameter;
134
136 OutputDataType mask;
137
139 double ratio;
140
142 double alphaDash;
143
145 bool deterministic;
146
148 static constexpr double alpha = 1.6732632423543772848170429916717;
149
151 static constexpr double lambda = 1.0507009873554804934193349852946;
152
154 double a;
155
157 double b;
158}; // class AlphaDropout
159
160} // namespace ann
161} // namespace mlpack
162
163// Include implementation.
164#include "alpha_dropout_impl.hpp"
165
166#endif
The alpha - dropout layer is a regularizer that randomly with probability 'ratio' sets input values t...
double Ratio() const
The probability of setting a value to alphaDash.
OutputDataType const & Delta() const
Get the detla.
OutputDataType const & Mask() const
Get the mask.
double AlphaDash() const
Value of alphaDash.
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of the alpha_dropout layer.
OutputDataType const & OutputParameter() const
Get the output parameter.
void Ratio(const double r)
Modify the probability of setting a value to alphaDash.
bool & Deterministic()
Modify the value of the deterministic parameter.
bool Deterministic() const
The value of the deterministic parameter.
double A() const
Value to be multiplied with x for affine transformation.
double B() const
Value to be added to a*x for affine transformation.
AlphaDropout(const double ratio=0.5, const double alphaDash=-alpha *lambda)
Create the Alpha_Dropout object using the specified ratio.
void Backward(const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of the alpha_dropout layer.
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.