mlpack
master
|
The DropConnect layer is a regularizer that randomly with probability ratio sets the connection values to zero and scales the remaining elements by factor 1 /(1 - ratio). More...
Public Member Functions | |
DropConnect () | |
Create the DropConnect object. More... | |
DropConnect (const size_t inSize, const size_t outSize, const double ratio=0.5) | |
Creates the DropConnect Layer as a Linear Object that takes input size, output size and ratio as parameter. More... | |
~DropConnect () | |
template<typename eT > | |
void | Backward (arma::Mat< eT > &&input, arma::Mat< eT > &&gy, arma::Mat< eT > &&g) |
Ordinary feed backward pass of the DropConnect layer. More... | |
OutputDataType const & | Delta () const |
Get the delta. 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 (arma::Mat< eT > &&input, arma::Mat< eT > &&output) |
Ordinary feed forward pass of the DropConnect layer. More... | |
template<typename eT > | |
void | Gradient (arma::Mat< eT > &&input, arma::Mat< eT > &&error, arma::Mat< eT > &&) |
Calculate the gradient using the output delta and the input activation. More... | |
OutputDataType const & | Gradient () const |
Get the gradient. More... | |
OutputDataType & | Gradient () |
Modify the gradient. More... | |
InputDataType const & | InputParameter () const |
Get the input parameter. More... | |
InputDataType & | InputParameter () |
Modify the input parameter. More... | |
std::vector< LayerTypes > & | Model () |
Get the model modules. More... | |
OutputDataType const & | OutputParameter () const |
Get the output parameter. More... | |
OutputDataType & | OutputParameter () |
Modify the output parameter. More... | |
OutputDataType const & | Parameters () const |
Get the parameters. More... | |
OutputDataType & | Parameters () |
Modify the parameters. 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... | |
template<typename Archive > | |
void | Serialize (Archive &ar, const unsigned int) |
Serialize the layer. More... | |
Private Attributes | |
LayerTypes | baseLayer |
Locally-stored layer module. More... | |
OutputDataType | delta |
Locally-stored delta object. More... | |
OutputDataType | denoise |
Denoise mask for the weights. More... | |
bool | deterministic |
If true dropout and scaling is disabled, see notes above. More... | |
OutputDataType | gradient |
Locally-stored gradient object. More... | |
InputDataType | inputParameter |
Locally-stored input parameter object. More... | |
OutputDataType | mask |
Locally-stored mask object. More... | |
std::vector< LayerTypes > | network |
Locally-stored network modules. More... | |
OutputDataType | outputParameter |
Locally-stored output parameter object. More... | |
OutputDataType | parameters |
Locally-stored weight object. More... | |
double | ratio |
The probability of setting a value to zero. More... | |
double | scale |
The scale fraction. More... | |
The DropConnect layer is a regularizer that randomly with probability ratio sets the connection values to zero and scales the remaining elements by factor 1 /(1 - ratio).
The output is scaled with 1 / (1 - p) when deterministic is false. In the deterministic mode(during testing), the layer just computes the output. The output is computed according to the input layer. If no input layer is given, it will take a linear layer as default.
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 62 of file dropconnect.hpp.
mlpack::ann::DropConnect< InputDataType, OutputDataType >::DropConnect | ( | ) |
Create the DropConnect object.
mlpack::ann::DropConnect< InputDataType, OutputDataType >::DropConnect | ( | const size_t | inSize, |
const size_t | outSize, | ||
const double | ratio = 0.5 |
||
) |
Creates the DropConnect Layer as a Linear Object that takes input size, output size and ratio as parameter.
inSize | The number of input units. |
outSize | The number of output units. |
ratio | The probability of setting a value to zero. |
mlpack::ann::DropConnect< InputDataType, OutputDataType >::~DropConnect | ( | ) |
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Backward | ( | arma::Mat< eT > && | input, |
arma::Mat< eT > && | gy, | ||
arma::Mat< eT > && | g | ||
) |
Ordinary feed backward pass of the DropConnect layer.
input | The propagated input activation. |
gy | The backpropagated error. |
g | The calculated gradient. |
|
inline |
Get the delta.
Definition at line 134 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::delta.
|
inline |
Modify the delta.
Definition at line 136 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::delta.
|
inline |
The value of the deterministic parameter.
Definition at line 144 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::deterministic.
|
inline |
Modify the value of the deterministic parameter.
Definition at line 147 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::deterministic.
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Forward | ( | arma::Mat< eT > && | input, |
arma::Mat< eT > && | output | ||
) |
Ordinary feed forward pass of the DropConnect layer.
input | Input data used for evaluating the specified function. |
output | Resulting output activation. |
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Gradient | ( | arma::Mat< eT > && | input, |
arma::Mat< eT > && | error, | ||
arma::Mat< eT > && | |||
) |
Calculate the gradient using the output delta and the input activation.
input | The propagated input. |
d | The calculated error. |
g | The calculated gradient. |
|
inline |
Get the gradient.
Definition at line 139 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::gradient.
|
inline |
Modify the gradient.
Definition at line 141 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::gradient.
|
inline |
Get the input parameter.
Definition at line 124 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::inputParameter.
|
inline |
Modify the input parameter.
Definition at line 126 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::inputParameter.
|
inline |
Get the model modules.
Definition at line 116 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::network.
|
inline |
Get the output parameter.
Definition at line 129 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::outputParameter.
|
inline |
Modify the output parameter.
Definition at line 131 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::outputParameter.
|
inline |
Get the parameters.
Definition at line 119 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::parameters.
|
inline |
Modify the parameters.
Definition at line 121 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::parameters.
|
inline |
The probability of setting a value to zero.
Definition at line 150 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::ratio.
|
inline |
Modify the probability of setting a value to zero.
Definition at line 153 of file dropconnect.hpp.
References mlpack::ann::DropConnect< InputDataType, OutputDataType >::ratio, mlpack::ann::DropConnect< InputDataType, OutputDataType >::scale, and mlpack::ann::DropConnect< InputDataType, OutputDataType >::Serialize().
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the layer.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Ratio().
|
private |
Locally-stored layer module.
Definition at line 197 of file dropconnect.hpp.
|
private |
Locally-stored delta object.
Definition at line 176 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Delta().
|
private |
Denoise mask for the weights.
Definition at line 194 of file dropconnect.hpp.
|
private |
If true dropout and scaling is disabled, see notes above.
Definition at line 191 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Deterministic().
|
private |
Locally-stored gradient object.
Definition at line 179 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Gradient().
|
private |
Locally-stored input parameter object.
Definition at line 182 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::InputParameter().
|
private |
Locally-stored mask object.
Definition at line 188 of file dropconnect.hpp.
|
private |
Locally-stored network modules.
Definition at line 200 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Model().
|
private |
Locally-stored output parameter object.
Definition at line 185 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::OutputParameter().
|
private |
Locally-stored weight object.
Definition at line 173 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Parameters().
|
private |
The probability of setting a value to zero.
Definition at line 167 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Ratio().
|
private |
The scale fraction.
Definition at line 170 of file dropconnect.hpp.
Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Ratio().