mlpack
master
|
The dropout layer is a regularizer that randomly with probability ratio sets input values to zero and scales the remaining elements by factor 1 / (1 - ratio). More...
Public Member Functions | |
Dropout (const double ratio=0.5, const bool rescale=true) | |
Create the Dropout object using the specified ratio and rescale parameter. More... | |
template<typename eT > | |
void | Backward (const arma::Mat< eT > &&, arma::Mat< eT > &&gy, arma::Mat< eT > &&g) |
Ordinary feed backward pass of the dropout layer. More... | |
OutputDataType const & | Delta () const |
Get the detla. More... | |
OutputDataType & | Delta () |
Modify the delta. More... | |
bool | Deterministic () const |
The value of the deterministic parameter. More... | |
bool & | Deterministic () |
Modify the value of the deterministic parameter. More... | |
template<typename eT > | |
void | Forward (const arma::Mat< eT > &&input, arma::Mat< eT > &&output) |
Ordinary feed forward pass of the dropout layer. More... | |
InputDataType const & | InputParameter () const |
Get the input parameter. More... | |
InputDataType & | InputParameter () |
Modify the input parameter. More... | |
OutputDataType const & | OutputParameter () const |
Get the output parameter. More... | |
OutputDataType & | OutputParameter () |
Modify the output parameter. More... | |
double | Ratio () const |
The probability of setting a value to zero. More... | |
void | Ratio (const double r) |
Modify the probability of setting a value to zero. More... | |
bool | Rescale () const |
The value of the rescale parameter. More... | |
bool & | Rescale () |
Modify the value of the rescale parameter. More... | |
template<typename Archive > | |
void | Serialize (Archive &ar, const unsigned int) |
Serialize the layer. More... | |
Private Attributes | |
OutputDataType | delta |
Locally-stored delta object. More... | |
bool | deterministic |
If true dropout and scaling is disabled, see notes above. More... | |
InputDataType | inputParameter |
Locally-stored input parameter object. More... | |
OutputDataType | mask |
Locally-stored mast object. More... | |
OutputDataType | outputParameter |
Locally-stored output parameter object. More... | |
double | ratio |
The probability of setting a value to zero. More... | |
bool | rescale |
If true the input is rescaled when deterministic is False. More... | |
double | scale |
The scale fraction. More... | |
The dropout layer is a regularizer that randomly with probability ratio sets input values to zero and scales the remaining elements by factor 1 / (1 - ratio).
If rescale is true the input is scaled with 1 / (1-p) when deterministic is false. In the deterministic mode (during testing), the layer just scales the output.
Note: During training you should set deterministic to false and during testing you should set deterministic to true.
For more information, see the following.
InputDataType | Type of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
OutputDataType | Type of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
Definition at line 54 of file dropout.hpp.
mlpack::ann::Dropout< InputDataType, OutputDataType >::Dropout | ( | const double | ratio = 0.5 , |
const bool | rescale = true |
||
) |
Create the Dropout object using the specified ratio and rescale parameter.
ratio | The probability of setting a value to zero. |
rescale | If true the input is rescaled when deterministic is False. |
void mlpack::ann::Dropout< InputDataType, OutputDataType >::Backward | ( | const arma::Mat< eT > && | , |
arma::Mat< eT > && | gy, | ||
arma::Mat< eT > && | g | ||
) |
Ordinary feed backward pass of the dropout layer.
input | The propagated input activation. |
gy | The backpropagated error. |
g | The calculated gradient. |
|
inline |
Get the detla.
Definition at line 98 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::delta.
|
inline |
Modify the delta.
Definition at line 100 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::delta.
|
inline |
The value of the deterministic parameter.
Definition at line 103 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::deterministic.
|
inline |
Modify the value of the deterministic parameter.
Definition at line 105 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::deterministic.
void mlpack::ann::Dropout< InputDataType, OutputDataType >::Forward | ( | const arma::Mat< eT > && | input, |
arma::Mat< eT > && | output | ||
) |
Ordinary feed forward pass of the dropout layer.
input | Input data used for evaluating the specified function. |
output | Resulting output activation. |
|
inline |
Get the input parameter.
Definition at line 88 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::inputParameter.
|
inline |
Modify the input parameter.
Definition at line 90 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::inputParameter.
|
inline |
Get the output parameter.
Definition at line 93 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::outputParameter.
|
inline |
Modify the output parameter.
Definition at line 95 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::outputParameter.
|
inline |
The probability of setting a value to zero.
Definition at line 108 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::ratio.
|
inline |
Modify the probability of setting a value to zero.
Definition at line 111 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::ratio, and mlpack::ann::Dropout< InputDataType, OutputDataType >::scale.
|
inline |
The value of the rescale parameter.
Definition at line 118 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::rescale.
|
inline |
Modify the value of the rescale parameter.
Definition at line 120 of file dropout.hpp.
References mlpack::ann::Dropout< InputDataType, OutputDataType >::rescale, and mlpack::ann::Dropout< InputDataType, OutputDataType >::Serialize().
void mlpack::ann::Dropout< InputDataType, OutputDataType >::Serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the layer.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::Rescale().
|
private |
Locally-stored delta object.
Definition at line 130 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::Delta().
|
private |
If true dropout and scaling is disabled, see notes above.
Definition at line 148 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::Deterministic().
|
private |
Locally-stored input parameter object.
Definition at line 133 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::InputParameter().
|
private |
Locally-stored mast object.
Definition at line 139 of file dropout.hpp.
|
private |
Locally-stored output parameter object.
Definition at line 136 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::OutputParameter().
|
private |
The probability of setting a value to zero.
Definition at line 142 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::Ratio().
|
private |
If true the input is rescaled when deterministic is False.
Definition at line 151 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::Rescale().
|
private |
The scale fraction.
Definition at line 145 of file dropout.hpp.
Referenced by mlpack::ann::Dropout< InputDataType, OutputDataType >::Ratio().