shark::MeanModel< ModelType > Class Template Reference

Calculates the weighted mean of a set of models. More...

#include <shark/Models/MeanModel.h>

+ Inheritance diagram for shark::MeanModel< ModelType >:

Public Member Functions

 MeanModel ()
 Constructor. More...
 
std::string name () const
 returns the name of the object More...
 
void eval (typename base_type::BatchInputType const &patterns, typename base_type::BatchOutputType &outputs) const
 
void eval (typename base_type::BatchInputType const &patterns, typename base_type::BatchOutputType &outputs, State &state) const
 
RealVector parameterVector () const
 This model does not have any parameters. More...
 
void setParameterVector (const RealVector &param)
 This model does not have any parameters. More...
 
void read (InArchive &archive)
 From ISerializable, reads a model from an archive. More...
 
void write (OutArchive &archive) const
 writes a model to an archive More...
 
void clearModels ()
 Removes all models from the ensemble. More...
 
void addModel (ModelType const &model, double weight=1.0)
 Adds a new model to the ensemble. More...
 
double const & weight (std::size_t i) const
 Returns the weight of the i-th model. More...
 
void setWeight (std::size_t i, double newWeight)
 sets the weight of the i-th model More...
 
std::size_t numberOfModels () const
 Returns the number of models. More...
 
- Public Member Functions inherited from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >
 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 boost::shared_ptr< StatecreateState () const
 Creates an internal state of the model. More...
 
virtual void eval (BatchInputType const &patterns, BatchOutputType &outputs) const
 Standard interface for evaluating the response of the model to a batch of patterns. More...
 
virtual void eval (BatchInputType const &patterns, BatchOutputType &outputs, State &state) const=0
 Standard interface for evaluating the response of the model to a batch of patterns. 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 ()
 
virtual std::size_t numberOfParameters () const
 Return the number of parameters. More...
 
- 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 ()
 

Protected Attributes

std::vector< ModelType > m_models
 collection of models. More...
 
std::vector< double > m_weight
 Weight of the mean. More...
 
double m_weightSum
 Total sum of weights. More...
 
- Protected Attributes inherited from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >
Features m_features
 

Additional Inherited Members

- Public Types inherited from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >
enum  Feature
 
typedef ModelType::InputType InputType
 Defines the input type of the model. More...
 
typedef ModelType::OutputType 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
 

Detailed Description

template<class ModelType>
class shark::MeanModel< ModelType >

Calculates the weighted mean of a set of models.

Definition at line 43 of file MeanModel.h.

Constructor & Destructor Documentation

§ MeanModel()

template<class ModelType>
shark::MeanModel< ModelType >::MeanModel ( )
inline

Constructor.

Definition at line 50 of file MeanModel.h.

Member Function Documentation

§ addModel()

template<class ModelType>
void shark::MeanModel< ModelType >::addModel ( ModelType const &  model,
double  weight = 1.0 
)
inline

Adds a new model to the ensemble.

Parameters
modelthe new model
weightweight of the model. must be > 0

Definition at line 100 of file MeanModel.h.

§ clearModels()

template<class ModelType>
void shark::MeanModel< ModelType >::clearModels ( )
inline

Removes all models from the ensemble.

Definition at line 90 of file MeanModel.h.

§ eval() [1/2]

template<class ModelType>
void shark::MeanModel< ModelType >::eval ( typename base_type::BatchInputType const &  patterns,
typename base_type::BatchOutputType outputs 
) const
inline

Definition at line 56 of file MeanModel.h.

Referenced by shark::MeanModel< CARTClassifier< RealVector > >::eval().

§ eval() [2/2]

template<class ModelType>
void shark::MeanModel< ModelType >::eval ( typename base_type::BatchInputType const &  patterns,
typename base_type::BatchOutputType outputs,
State state 
) const
inline

Definition at line 64 of file MeanModel.h.

§ name()

template<class ModelType>
std::string shark::MeanModel< ModelType >::name ( ) const
inlinevirtual

returns the name of the object

Reimplemented from shark::INameable.

Definition at line 52 of file MeanModel.h.

§ numberOfModels()

template<class ModelType>
std::size_t shark::MeanModel< ModelType >::numberOfModels ( ) const
inline

Returns the number of models.

Definition at line 119 of file MeanModel.h.

§ parameterVector()

template<class ModelType>
RealVector shark::MeanModel< ModelType >::parameterVector ( ) const
inlinevirtual

This model does not have any parameters.

Reimplemented from shark::IParameterizable.

Definition at line 70 of file MeanModel.h.

§ read()

template<class ModelType>
void shark::MeanModel< ModelType >::read ( InArchive archive)
inlinevirtual

From ISerializable, reads a model from an archive.

Reimplemented from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >.

Definition at line 78 of file MeanModel.h.

§ setParameterVector()

template<class ModelType>
void shark::MeanModel< ModelType >::setParameterVector ( const RealVector &  param)
inlinevirtual

This model does not have any parameters.

Reimplemented from shark::IParameterizable.

Definition at line 75 of file MeanModel.h.

§ setWeight()

template<class ModelType>
void shark::MeanModel< ModelType >::setWeight ( std::size_t  i,
double  newWeight 
)
inline

sets the weight of the i-th model

Definition at line 113 of file MeanModel.h.

§ weight()

template<class ModelType>
double const& shark::MeanModel< ModelType >::weight ( std::size_t  i) const
inline

Returns the weight of the i-th model.

Definition at line 108 of file MeanModel.h.

Referenced by shark::MeanModel< CARTClassifier< RealVector > >::addModel().

§ write()

template<class ModelType>
void shark::MeanModel< ModelType >::write ( OutArchive archive) const
inlinevirtual

writes a model to an archive

the default implementation just saves the parameters, not the structure!

Reimplemented from shark::AbstractModel< ModelType::InputType, ModelType::OutputType >.

Definition at line 83 of file MeanModel.h.

Member Data Documentation

§ m_models

§ m_weight

§ m_weightSum


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