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 
21 namespace mlpack {
22 namespace ann {
23 
47 template <typename InputDataType = arma::mat,
48  typename OutputDataType = arma::mat>
50 {
51  public:
58  AlphaDropout(const double ratio = 0.5,
59  const double alphaDash = -alpha * lambda);
60 
67  template<typename eT>
68  void Forward(const arma::Mat<eT>&& input, arma::Mat<eT>&& output);
69 
77  template<typename eT>
78  void Backward(const arma::Mat<eT>&& /* input */,
79  arma::Mat<eT>&& gy,
80  arma::Mat<eT>&& g);
81 
83  OutputDataType const& OutputParameter() const { return outputParameter; }
85  OutputDataType& OutputParameter() { return outputParameter; }
86 
88  OutputDataType const& Delta() const { return delta; }
90  OutputDataType& Delta() { return delta; }
91 
93  bool Deterministic() const { return deterministic; }
95  bool& Deterministic() { return deterministic; }
96 
98  double Ratio() const { return ratio; }
99 
101  double A() const { return a; }
102 
104  double B() const { return b; }
105 
107  double AlphaDash() const {return alphaDash; }
108 
110  OutputDataType const& Mask() const {return mask;}
111 
114  void Ratio(const double r)
115  {
116  ratio = r;
117  a = pow((1 - ratio) * (1 + ratio * pow(alphaDash, 2)), -0.5);
118  b = -a * alphaDash * ratio;
119  }
120 
124  template<typename Archive>
125  void serialize(Archive& ar, const unsigned int /* version */);
126 
127  private:
129  OutputDataType delta;
130 
132  OutputDataType outputParameter;
133 
135  OutputDataType mask;
136 
138  double ratio;
139 
141  double alphaDash;
142 
144  bool deterministic;
145 
147  static constexpr double alpha = 1.6732632423543772848170429916717;
148 
150  static constexpr double lambda = 1.0507009873554804934193349852946;
151 
153  double a;
154 
156  double b;
157 }; // class AlphaDropout
158 
159 } // namespace ann
160 } // namespace mlpack
161 
162 // Include implementation.
163 #include "alpha_dropout_impl.hpp"
164 
165 #endif
bool & Deterministic()
Modify the value of the deterministic parameter.
.hpp
Definition: add_to_po.hpp:21
double A() const
Value to be multiplied with x for affine transformation.
AlphaDropout(const double ratio=0.5, const double alphaDash=-alpha *lambda)
Create the Alpha_Dropout object using the specified ratio.
double Ratio() const
The probability of setting a value to alphaDash.
The core includes that mlpack expects; standard C++ includes and Armadillo.
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 & OutputParameter()
Modify the output parameter.
OutputDataType const & Mask() const
Get the mask.
double B() const
Value to be added to a*x for affine transformation.
OutputDataType const & Delta() const
Get the detla.
void Ratio(const double r)
Modify the probability of setting a value to alphaDash.
The alpha - dropout layer is a regularizer that randomly with probability &#39;ratio&#39; sets input values t...
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
bool Deterministic() const
The value of the deterministic parameter.
OutputDataType const & OutputParameter() const
Get the output parameter.
OutputDataType & Delta()
Modify the delta.
void Backward(const arma::Mat< eT > &&, arma::Mat< eT > &&gy, arma::Mat< eT > &&g)
Ordinary feed backward pass of the alpha_dropout layer.