shark::ImpulseNoiseModel Class Reference

Model which corrupts the data using Impulse noise. More...

#include <shark/Models/ImpulseNoiseModel.h>

+ Inheritance diagram for shark::ImpulseNoiseModel:

Public Member Functions

 ImpulseNoiseModel ()
 Default Constructor; use setStructure later. More...
 
 ImpulseNoiseModel (unsigned int inputs, double prob, double value=0.0)
 Constructor creating a model with given input size and a probability to set values of the input to a given value. More...
 
std::string name () const
 From INameable: return the class name. More...
 
size_t inputSize () const
 obtain the input dimension More...
 
size_t outputSize () const
 obtain the output dimension More...
 
RealVector parameterVector () const
 obtain the parameter vector More...
 
void setParameterVector (RealVector const &newParameters)
 overwrite the parameter vector More...
 
size_t numberOfParameters () const
 return the number of parameter More...
 
boost::shared_ptr< StatecreateState () const
 Creates an internal state of the model. More...
 
void eval (BatchInputType const &inputs, BatchOutputType &outputs) const
 Add noise to the input. More...
 
void eval (BatchInputType const &inputs, BatchOutputType &outputs, State &state) const
 Evaluate the model: output = matrix * input + offset. More...
 
void weightedParameterDerivative (BatchInputType const &patterns, RealVector const &coefficients, State const &state, RealVector &gradient) const
 
- Public Member Functions inherited from shark::AbstractModel< RealVector, RealVector >
 AbstractModel ()
 
virtual ~AbstractModel ()
 
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool hasFirstParameterDerivative () const
 Returns true when the first parameter derivative is implemented. More...
 
bool hasSecondParameterDerivative () const
 Returns true when the second parameter derivative is implemented. More...
 
bool hasFirstInputDerivative () const
 Returns true when the first input derivative is implemented. More...
 
bool hasSecondInputDerivative () const
 Returns true when the second parameter derivative is implemented. More...
 
bool isSequential () const
 
virtual void read (InArchive &archive)
 From ISerializable, reads a model from an archive. More...
 
virtual void write (OutArchive &archive) const
 writes a model to an archive More...
 
virtual void eval (InputType const &pattern, OutputType &output) const
 Standard interface for evaluating the response of the model to a single pattern. More...
 
Data< OutputTypeoperator() (Data< InputType > const &patterns) const
 Model evaluation as an operator for a whole dataset. This is a convenience function. More...
 
OutputType operator() (InputType const &pattern) const
 Model evaluation as an operator for a single pattern. This is a convenience function. More...
 
BatchOutputType operator() (BatchInputType const &patterns) const
 Model evaluation as an operator for a single pattern. This is a convenience function. More...
 
virtual void weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, State const &state, RealVector &derivative) const
 calculates the weighted sum of derivatives w.r.t the parameters. More...
 
virtual void weightedParameterDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, Batch< RealMatrix >::type const &errorHessian, State const &state, RealVector &derivative, RealMatrix &hessian) const
 calculates the weighted sum of derivatives w.r.t the parameters More...
 
virtual void weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const
 calculates the weighted sum of derivatives w.r.t the inputs More...
 
virtual void weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &coefficients, typename Batch< RealMatrix >::type const &errorHessian, State const &state, RealMatrix &derivative, Batch< RealMatrix >::type &hessian) const
 calculates the weighted sum of derivatives w.r.t the inputs More...
 
virtual void weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &coefficients, State const &state, RealVector &parameterDerivative, BatchInputType &inputDerivative) const
 calculates weighted input and parameter derivative at the same time More...
 
- Public Member Functions inherited from shark::IParameterizable
virtual ~IParameterizable ()
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor. More...
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...). More...
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...). More...
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 

Additional Inherited Members

- Public Types inherited from shark::AbstractModel< RealVector, RealVector >
enum  Feature
 
typedef RealVector InputType
 Defines the input type of the model. More...
 
typedef RealVector OutputType
 Defines the output type of the model. More...
 
typedef Batch< InputType >::type BatchInputType
 defines the batch type of the input type. More...
 
typedef Batch< OutputType >::type BatchOutputType
 defines the batch type of the output type More...
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 
- Protected Attributes inherited from shark::AbstractModel< RealVector, RealVector >
Features m_features
 

Detailed Description

Model which corrupts the data using Impulse noise.

We define impulse noise as a noise which randomly sets the value of an element in a vector to a given value, 0 by default. We chose the name as with for example a noise of 1, impulses can be seen in the visualised vectors.

very input dimension is tested independently.

This noise can be used to implement denoising autoencoders for binary data.

Definition at line 49 of file ImpulseNoiseModel.h.

Constructor & Destructor Documentation

◆ ImpulseNoiseModel() [1/2]

shark::ImpulseNoiseModel::ImpulseNoiseModel ( )
inline

◆ ImpulseNoiseModel() [2/2]

shark::ImpulseNoiseModel::ImpulseNoiseModel ( unsigned int  inputs,
double  prob,
double  value = 0.0 
)
inline

Constructor creating a model with given input size and a probability to set values of the input to a given value.

Definition at line 63 of file ImpulseNoiseModel.h.

References shark::AbstractModel< RealVector, RealVector >::HAS_FIRST_PARAMETER_DERIVATIVE, and shark::AbstractModel< RealVector, RealVector >::m_features.

Member Function Documentation

◆ createState()

boost::shared_ptr<State> shark::ImpulseNoiseModel::createState ( ) const
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< RealVector, RealVector >.

Definition at line 97 of file ImpulseNoiseModel.h.

◆ eval() [1/2]

void shark::ImpulseNoiseModel::eval ( BatchInputType const &  inputs,
BatchOutputType outputs 
) const
inlinevirtual

Add noise to the input.

Reimplemented from shark::AbstractModel< RealVector, RealVector >.

Definition at line 102 of file ImpulseNoiseModel.h.

References shark::coinToss(), inputSize(), SHARK_CRITICAL_REGION, and SIZE_CHECK.

Referenced by eval().

◆ eval() [2/2]

void shark::ImpulseNoiseModel::eval ( BatchInputType const &  inputs,
BatchOutputType outputs,
State state 
) const
inlinevirtual

Evaluate the model: output = matrix * input + offset.

Implements shark::AbstractModel< RealVector, RealVector >.

Definition at line 116 of file ImpulseNoiseModel.h.

References eval().

◆ inputSize()

size_t shark::ImpulseNoiseModel::inputSize ( ) const
inline

obtain the input dimension

Definition at line 73 of file ImpulseNoiseModel.h.

Referenced by eval().

◆ name()

std::string shark::ImpulseNoiseModel::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 69 of file ImpulseNoiseModel.h.

◆ numberOfParameters()

size_t shark::ImpulseNoiseModel::numberOfParameters ( ) const
inlinevirtual

return the number of parameter

Reimplemented from shark::IParameterizable.

Definition at line 94 of file ImpulseNoiseModel.h.

◆ outputSize()

size_t shark::ImpulseNoiseModel::outputSize ( ) const
inline

obtain the output dimension

Definition at line 78 of file ImpulseNoiseModel.h.

◆ parameterVector()

RealVector shark::ImpulseNoiseModel::parameterVector ( ) const
inlinevirtual

obtain the parameter vector

Reimplemented from shark::IParameterizable.

Definition at line 83 of file ImpulseNoiseModel.h.

◆ setParameterVector()

void shark::ImpulseNoiseModel::setParameterVector ( RealVector const &  newParameters)
inlinevirtual

overwrite the parameter vector

Reimplemented from shark::IParameterizable.

Definition at line 88 of file ImpulseNoiseModel.h.

References SIZE_CHECK.

◆ weightedParameterDerivative()

void shark::ImpulseNoiseModel::weightedParameterDerivative ( BatchInputType const &  patterns,
RealVector const &  coefficients,
State const &  state,
RealVector &  gradient 
) const
inline

Definition at line 120 of file ImpulseNoiseModel.h.


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