mlpack  master
Public Member Functions | Private Attributes | List of all members
mlpack::ann::DropConnect< InputDataType, OutputDataType > Class Template Reference

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< LayerTypesnetwork
 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...
 

Detailed Description

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
class mlpack::ann::DropConnect< InputDataType, OutputDataType >

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.

@inproceedings{WanICML2013,
title={Regularization of Neural Networks using DropConnect},
booktitle = {Proceedings of the 30th International Conference on Machine
Learning(ICML - 13)},
author = {Li Wan and Matthew Zeiler and Sixin Zhang and Yann L. Cun and
Rob Fergus},
year = {2013}
}
Template Parameters
InputDataTypeType of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).
OutputDataTypeType of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).

Definition at line 62 of file dropconnect.hpp.

Constructor & Destructor Documentation

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
mlpack::ann::DropConnect< InputDataType, OutputDataType >::DropConnect ( )

Create the DropConnect object.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
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.

Parameters
inSizeThe number of input units.
outSizeThe number of output units.
ratioThe probability of setting a value to zero.
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
mlpack::ann::DropConnect< InputDataType, OutputDataType >::~DropConnect ( )

Member Function Documentation

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename eT >
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.

Parameters
inputThe propagated input activation.
gyThe backpropagated error.
gThe calculated gradient.
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType const& mlpack::ann::DropConnect< InputDataType, OutputDataType >::Delta ( ) const
inline

Get the delta.

Definition at line 134 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::delta.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType& 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.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool mlpack::ann::DropConnect< InputDataType, OutputDataType >::Deterministic ( ) const
inline

The value of the deterministic parameter.

Definition at line 144 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::deterministic.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool& 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.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename eT >
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Forward ( arma::Mat< eT > &&  input,
arma::Mat< eT > &&  output 
)

Ordinary feed forward pass of the DropConnect layer.

Parameters
inputInput data used for evaluating the specified function.
outputResulting output activation.
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename eT >
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.

Parameters
inputThe propagated input.
dThe calculated error.
gThe calculated gradient.
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType const& mlpack::ann::DropConnect< InputDataType, OutputDataType >::Gradient ( ) const
inline

Get the gradient.

Definition at line 139 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::gradient.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType& 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.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType const& mlpack::ann::DropConnect< InputDataType, OutputDataType >::InputParameter ( ) const
inline

Get the input parameter.

Definition at line 124 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::inputParameter.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType& 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.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
std::vector<LayerTypes>& mlpack::ann::DropConnect< InputDataType, OutputDataType >::Model ( )
inline

Get the model modules.

Definition at line 116 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::network.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType const& mlpack::ann::DropConnect< InputDataType, OutputDataType >::OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 129 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::outputParameter.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType& 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.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType const& mlpack::ann::DropConnect< InputDataType, OutputDataType >::Parameters ( ) const
inline

Get the parameters.

Definition at line 119 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::parameters.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType& 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.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double mlpack::ann::DropConnect< InputDataType, OutputDataType >::Ratio ( ) const
inline

The probability of setting a value to zero.

Definition at line 150 of file dropconnect.hpp.

References mlpack::ann::DropConnect< InputDataType, OutputDataType >::ratio.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Ratio ( const double  r)
inline
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
template<typename Archive >
void mlpack::ann::DropConnect< InputDataType, OutputDataType >::Serialize ( Archive &  ar,
const unsigned  int 
)

Member Data Documentation

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
LayerTypes mlpack::ann::DropConnect< InputDataType, OutputDataType >::baseLayer
private

Locally-stored layer module.

Definition at line 197 of file dropconnect.hpp.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::delta
private

Locally-stored delta object.

Definition at line 176 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Delta().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::denoise
private

Denoise mask for the weights.

Definition at line 194 of file dropconnect.hpp.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool mlpack::ann::DropConnect< InputDataType, OutputDataType >::deterministic
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().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::gradient
private

Locally-stored gradient object.

Definition at line 179 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Gradient().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::inputParameter
private

Locally-stored input parameter object.

Definition at line 182 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::InputParameter().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::mask
private

Locally-stored mask object.

Definition at line 188 of file dropconnect.hpp.

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
std::vector<LayerTypes> mlpack::ann::DropConnect< InputDataType, OutputDataType >::network
private

Locally-stored network modules.

Definition at line 200 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Model().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::outputParameter
private

Locally-stored output parameter object.

Definition at line 185 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::OutputParameter().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
OutputDataType mlpack::ann::DropConnect< InputDataType, OutputDataType >::parameters
private

Locally-stored weight object.

Definition at line 173 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Parameters().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double mlpack::ann::DropConnect< InputDataType, OutputDataType >::ratio
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().

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
double mlpack::ann::DropConnect< InputDataType, OutputDataType >::scale
private

The scale fraction.

Definition at line 170 of file dropconnect.hpp.

Referenced by mlpack::ann::DropConnect< InputDataType, OutputDataType >::Ratio().


The documentation for this class was generated from the following file: