DropoutType< MatType > Class Template Reference

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) rather than during test time so as to keep the expected sum same. More...

Inheritance diagram for DropoutType< MatType >:

Public Member Functions

 DropoutType (const double ratio=0.5)
 Create the Dropout object using the specified ratio parameter. More...

 
 DropoutType (const DropoutType &other)
 Copy the given DropoutType. More...

 
 DropoutType (DropoutType &&other)
 Take ownership of the given DropoutType. More...

 
virtual ~DropoutType ()
 
void Backward (const MatType &, const MatType &gy, MatType &g)
 Ordinary feed backward pass of the dropout layer. More...

 
DropoutTypeClone () const
 Clone the DropoutType object. This handles polymorphism correctly. More...

 
void Forward (const MatType &input, MatType &output)
 Ordinary feed forward pass of the dropout layer. More...

 
DropoutTypeoperator= (const DropoutType &other)
 Copy the given DropoutType. More...

 
DropoutTypeoperator= (DropoutType &&other)
 Take ownership of the given DropoutType. 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 uint32_t)
 Serialize the layer. More...

 
- Public Member Functions inherited from Layer< MatType >
 Layer ()
 Default constructor. More...

 
 Layer (const Layer &layer)
 Copy constructor. This is not responsible for copying weights! More...

 
 Layer (Layer &&layer)
 Move constructor. This is not responsible for moving weights! More...

 
virtual ~Layer ()
 Default deconstructor. More...

 
virtual void ComputeOutputDimensions ()
 Compute the output dimensions. More...

 
virtual void CustomInitialize (MatType &, const size_t)
 Override the weight matrix of the layer. More...

 
virtual void Forward (const MatType &, const MatType &)
 Takes an input and output object, and computes the corresponding loss of the layer. More...

 
virtual void Gradient (const MatType &, const MatType &, MatType &)
 Computing the gradient of the layer with respect to its own input. More...

 
const std::vector< size_t > & InputDimensions () const
 Get the input dimensions. More...

 
std::vector< size_t > & InputDimensions ()
 Modify the input dimensions. More...

 
virtual double Loss ()
 Get the layer loss. More...

 
virtual Layeroperator= (const Layer &layer)
 Copy assignment operator. This is not responsible for copying weights! More...

 
virtual Layeroperator= (Layer &&layer)
 Move assignment operator. This is not responsible for moving weights! More...

 
const std::vector< size_t > & OutputDimensions ()
 Get the output dimensions. More...

 
virtual size_t OutputSize () final
 Get the number of elements in the output from this layer. More...

 
virtual const MatType & Parameters () const
 Get the parameters. More...

 
virtual MatType & Parameters ()
 Set the parameters. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialize the layer. More...

 
virtual void SetWeights (typename MatType::elem_type *)
 Reset the layer parameter. More...

 
virtual bool const & Training () const
 Get whether the layer is currently in training mode. More...

 
virtual bool & Training ()
 Modify whether the layer is currently in training mode. More...

 
virtual size_t WeightSize () const
 Get the total number of trainable weights in the layer. More...

 

Additional Inherited Members

- Protected Attributes inherited from Layer< MatType >
std::vector< size_t > inputDimensions
 Logical input dimensions of each point. More...

 
std::vector< size_t > outputDimensions
 Logical output dimensions of each point. More...

 
bool training
 If true, the layer is in training mode; otherwise, it is in testing mode. More...

 
bool validOutputDimensions
 This is true if ComputeOutputDimensions() has been called, and outputDimensions can be considered to be up-to-date. More...

 

Detailed Description


template
<
typename
MatType
=
arma::mat
>

class mlpack::ann::DropoutType< MatType >

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) rather than during test time so as to keep the expected sum same.

When the layer is in testing mode, there is no change in the input.

For more information, see the following.

@article{Hinton2012,
author = {Geoffrey E. Hinton, Nitish Srivastava, Alex Krizhevsky,
Ilya Sutskever, Ruslan Salakhutdinov},
title = {Improving neural networks by preventing co-adaptation of feature
detectors},
journal = {CoRR},
volume = {abs/1207.0580},
year = {2012},
url = {https://arxiv.org/abs/1207.0580}
}
Template Parameters
MatTypeMatrix representation to accept as input and use for computation.

Definition at line 48 of file dropout.hpp.

Constructor & Destructor Documentation

◆ DropoutType() [1/3]

DropoutType ( const double  ratio = 0.5)

Create the Dropout object using the specified ratio parameter.

Parameters
ratioThe probability of setting a value to zero.

Referenced by DropoutType< MatType >::Clone(), and DropoutType< MatType >::~DropoutType().

◆ ~DropoutType()

◆ DropoutType() [2/3]

DropoutType ( const DropoutType< MatType > &  other)

Copy the given DropoutType.

◆ DropoutType() [3/3]

DropoutType ( DropoutType< MatType > &&  other)

Take ownership of the given DropoutType.

Member Function Documentation

◆ Backward()

void Backward ( const MatType &  ,
const MatType &  gy,
MatType &  g 
)
virtual

Ordinary feed backward pass of the dropout layer.

Parameters
*(input) The propagated input activation.
gyThe backpropagated error.
gThe calculated gradient.

Reimplemented from Layer< MatType >.

Referenced by DropoutType< MatType >::~DropoutType().

◆ Clone()

DropoutType* Clone ( ) const
inlinevirtual

Clone the DropoutType object. This handles polymorphism correctly.

Implements Layer< MatType >.

Definition at line 59 of file dropout.hpp.

References DropoutType< MatType >::DropoutType().

◆ Forward()

void Forward ( const MatType &  input,
MatType &  output 
)
virtual

Ordinary feed forward pass of the dropout layer.

Parameters
inputInput data used for evaluating the specified function.
outputResulting output activation.

Reimplemented from Layer< MatType >.

Referenced by DropoutType< MatType >::~DropoutType().

◆ operator=() [1/2]

DropoutType& operator= ( const DropoutType< MatType > &  other)

Copy the given DropoutType.

Referenced by DropoutType< MatType >::~DropoutType().

◆ operator=() [2/2]

DropoutType& operator= ( DropoutType< MatType > &&  other)

Take ownership of the given DropoutType.

◆ Ratio() [1/2]

double Ratio ( ) const
inline

The probability of setting a value to zero.

Definition at line 91 of file dropout.hpp.

◆ Ratio() [2/2]

void Ratio ( const double  r)
inline

Modify the probability of setting a value to zero.

Definition at line 94 of file dropout.hpp.

References DropoutType< MatType >::serialize().

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the layer.

Referenced by DropoutType< MatType >::Ratio().


The documentation for this class was generated from the following file:
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-git/src/mlpack/methods/ann/layer/dropout.hpp