Implements Dropout layer semantics. More...
#include <shark/Models/DropoutLayer.h>
Public Member Functions | |
DropoutLayer (Shape const &inputShape, double probability=0.5, random::rng_type &rng=random::globalRng) | |
std::string | name () const |
From INameable: return the class name. | |
ParameterVectorType | parameterVector () const |
obtain the parameter vector | |
void | setParameterVector (ParameterVectorType const &newParameters) |
overwrite the parameter vector | |
size_t | numberOfParameters () const |
return the number of parameter | |
Shape | inputShape () const |
Returns the expected shape of the input. | |
Shape | outputShape () const |
Returns the shape of the output. | |
boost::shared_ptr< State > | createState () const |
Creates an internal state of the model. | |
void | eval (BatchInputType const &inputs, BatchOutputType &outputs) const |
Standard interface for evaluating the response of the model to a batch of patterns. | |
void | eval (VectorType const &input, VectorType &output) const |
void | eval (BatchInputType const &inputs, BatchOutputType &outputs, State &state) const |
Standard interface for evaluating the response of the model to a batch of patterns. | |
void | weightedParameterDerivative (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, ParameterVectorType &gradient) const |
Calculates the first derivative w.r.t the parameters and summing them up over all patterns of the last computed batch. | |
void | weightedInputDerivative (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const |
Calculates the first derivative w.r.t the inputs and summs them up over all patterns of the last computed batch. | |
void | read (InArchive &archive) |
From ISerializable. | |
void | write (OutArchive &archive) const |
From ISerializable. | |
Public Member Functions inherited from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType > | |
AbstractModel () | |
virtual | ~AbstractModel () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstParameterDerivative () const |
Returns true when the first parameter derivative is implemented. | |
bool | hasFirstInputDerivative () const |
Returns true when the first input derivative is implemented. | |
virtual void | eval (InputType const &pattern, OutputType &output) const |
Standard interface for evaluating the response of the model to a single pattern. | |
Data< OutputType > | operator() (Data< InputType > const &patterns) const |
Model evaluation as an operator for a whole dataset. This is a convenience function. | |
OutputType | operator() (InputType const &pattern) const |
Model evaluation as an operator for a single pattern. This is a convenience function. | |
BatchOutputType | operator() (BatchInputType const &patterns) const |
Model evaluation as an operator for a single pattern. This is a convenience function. | |
virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, ParameterVectorType ¶meterDerivative, BatchInputType &inputDerivative) const |
calculates weighted input and parameter derivative at the same time | |
Public Member Functions inherited from shark::IParameterizable< VectorType > | |
virtual | ~IParameterizable () |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
virtual | ~ISerializable () |
Virtual d'tor. | |
void | load (InArchive &archive, unsigned int version) |
Versioned loading of components, calls read(...). | |
void | save (OutArchive &archive, unsigned int version) const |
Versioned storing of components, calls write(...). | |
BOOST_SERIALIZATION_SPLIT_MEMBER () | |
Additional Inherited Members | |
Protected Attributes inherited from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType > | |
Features | m_features |
Implements Dropout layer semantics.
A dropout layer drops its input, i.e. sets it to 0 with a given probability. This is done for each element separately. This means, model prodections are not deterministic any more. Thus, after training the output of several evaluations should be averaged.
Dropout during training often leads to better regularized solutions in deep neural networks.
Definition at line 48 of file DropoutLayer.h.
typedef base_type::BatchInputType shark::DropoutLayer< VectorType >::BatchInputType |
Definition at line 60 of file DropoutLayer.h.
typedef base_type::BatchOutputType shark::DropoutLayer< VectorType >::BatchOutputType |
Definition at line 61 of file DropoutLayer.h.
typedef base_type::ParameterVectorType shark::DropoutLayer< VectorType >::ParameterVectorType |
Definition at line 62 of file DropoutLayer.h.
|
inline |
Definition at line 64 of file DropoutLayer.h.
References shark::AbstractModel< VectorType, VectorType, VectorType >::HAS_FIRST_INPUT_DERIVATIVE, shark::AbstractModel< VectorType, VectorType, VectorType >::HAS_FIRST_PARAMETER_DERIVATIVE, and shark::AbstractModel< VectorType, VectorType, VectorType >::m_features.
|
inlinevirtual |
Creates an internal state of the model.
The state is needed when the derivatives are to be calculated. Eval can store a state which is then reused to speed up the calculations of the derivatives. This also allows eval to be evaluated in parallel!
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 98 of file DropoutLayer.h.
|
inlinevirtual |
Standard interface for evaluating the response of the model to a batch of patterns.
patterns | the inputs of the model |
outputs | the predictions or response of the model to every pattern |
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 104 of file DropoutLayer.h.
References shark::random::coinToss().
|
inlinevirtual |
Standard interface for evaluating the response of the model to a batch of patterns.
patterns | the inputs of the model |
outputs | the predictions or response of the model to every pattern |
state | intermediate results stored by eval which can be reused for derivative computation. |
Implements shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 125 of file DropoutLayer.h.
References shark::random::coinToss(), and shark::State::toState().
|
inline |
Definition at line 116 of file DropoutLayer.h.
References shark::random::coinToss().
|
inlinevirtual |
Returns the expected shape of the input.
Implements shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 90 of file DropoutLayer.h.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 71 of file DropoutLayer.h.
|
inlinevirtual |
return the number of parameter
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 85 of file DropoutLayer.h.
|
inlinevirtual |
Returns the shape of the output.
Implements shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 94 of file DropoutLayer.h.
|
inlinevirtual |
obtain the parameter vector
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 75 of file DropoutLayer.h.
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 165 of file DropoutLayer.h.
|
inlinevirtual |
overwrite the parameter vector
Reimplemented from shark::IParameterizable< VectorType >.
Definition at line 80 of file DropoutLayer.h.
References SIZE_CHECK.
|
inlinevirtual |
Calculates the first derivative w.r.t the inputs and summs them up over all patterns of the last computed batch.
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 149 of file DropoutLayer.h.
References SIZE_CHECK, and shark::State::toState().
|
inlinevirtual |
Calculates the first derivative w.r.t the parameters and summing them up over all patterns of the last computed batch.
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 138 of file DropoutLayer.h.
References SIZE_CHECK.
|
inlinevirtual |
From ISerializable.
Reimplemented from shark::AbstractModel< InputTypeT, OutputTypeT, ParameterVectorType >.
Definition at line 167 of file DropoutLayer.h.