16 #ifndef MLPACK_METHODS_ANN_LAYER_ALPHA_DROPOUT_IMPL_HPP 17 #define MLPACK_METHODS_ANN_LAYER_ALPHA_DROPOUT_IMPL_HPP 25 template<
typename InputDataType,
typename OutputDataType>
28 const double alphaDash) :
36 template<
typename InputDataType,
typename OutputDataType>
39 const arma::Mat<eT>& input, arma::Mat<eT>& output)
52 mask = arma::randu< arma::Mat<eT> >(input.n_rows, input.n_cols);
53 mask.transform( [&](
double val) {
return (val > ratio); } );
54 output = (input % mask + alphaDash * (1 - mask)) * a + b;
58 template<
typename InputDataType,
typename OutputDataType>
61 const arma::Mat<eT>& ,
const arma::Mat<eT>& gy, arma::Mat<eT>& g)
66 template<
typename InputDataType,
typename OutputDataType>
67 template<
typename Archive>
69 Archive& ar,
const uint32_t )
71 ar(CEREAL_NVP(ratio));
72 ar(CEREAL_NVP(alphaDash));
void Forward(const arma::Mat< eT > &input, arma::Mat< eT > &output)
Ordinary feed forward pass of the alpha_dropout layer.
Definition: alpha_dropout_impl.hpp:38
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
double Ratio() const
The probability of setting a value to alphaDash.
Definition: alpha_dropout.hpp:99
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: alpha_dropout_impl.hpp:68
void Backward(const arma::Mat< eT > &, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of the alpha_dropout layer.
Definition: alpha_dropout_impl.hpp:60
AlphaDropout(const double ratio=0.5, const double alphaDash=-alpha *lambda)
Create the Alpha_Dropout object using the specified ratio.
Definition: alpha_dropout_impl.hpp:26