Calculates the weighted mean of a set of models. More...
#include <shark/Models/MeanModel.h>
Public Types | |
typedef ModelBaseType::BatchInputType | BatchInputType |
typedef ModelBaseType::BatchOutputType | BatchOutputType |
typedef ModelBaseType::ParameterVectorType | ParameterVectorType |
Public Types inherited from shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType > | |
enum | Feature |
typedef ModelType::InputType | InputType |
Defines the input type of the model. More... | |
typedef RealVector | OutputType |
Defines the output type of the model. More... | |
typedef AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType > | ModelBaseType |
Defines the BaseType used by the model (this type). Useful for creating derived models. 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< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
Public Types inherited from shark::IParameterizable< ModelType::ParameterVectorType > | |
typedef ModelType::ParameterVectorType | ParameterVectorType |
Public Member Functions | |
MeanModel () | |
Constructor. More... | |
std::string | name () const |
returns the name of the object More... | |
Shape | inputShape () const |
Returns the expected shape of the input. More... | |
Shape | outputShape () const |
Returns the shape of the output. More... | |
void | eval (BatchInputType const &patterns, BatchOutputType &outputs) const |
Standard interface for evaluating the response of the model to a batch of patterns. More... | |
void | eval (BatchInputType const &patterns, BatchOutputType &outputs, State &state) const |
Standard interface for evaluating the response of the model to a batch of patterns. More... | |
std::size_t | outputSize () const |
ParameterVectorType | parameterVector () const |
This model does not have any parameters. More... | |
void | setParameterVector (ParameterVectorType const ¶m) |
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... | |
ModelType const & | getModel (std::size_t index) const |
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... | |
void | setOutputSize (std::size_t dim) |
sets the dimensionality of the output More... | |
std::size_t | numberOfModels () const |
Returns the number of models. More... | |
Public Member Functions inherited from shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType > | |
AbstractModel () | |
virtual | ~AbstractModel () |
const Features & | features () const |
virtual void | updateFeatures () |
bool | hasFirstParameterDerivative () const |
Returns true when the first parameter derivative is implemented. More... | |
bool | hasFirstInputDerivative () const |
Returns true when the first input derivative is implemented. More... | |
virtual boost::shared_ptr< State > | createState () const |
Creates an internal state of the model. 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< OutputType > | operator() (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 &outputs, BatchOutputType const &coefficients, State const &state, RealVector &derivative) const |
calculates the weighted sum of derivatives w.r.t the parameters. More... | |
virtual void | weightedInputDerivative (BatchInputType const &pattern, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, BatchInputType &derivative) const |
calculates the weighted sum of derivatives w.r.t the inputs More... | |
virtual void | weightedDerivatives (BatchInputType const &patterns, BatchOutputType const &outputs, BatchOutputType const &coefficients, State const &state, RealVector ¶meterDerivative, BatchInputType &inputDerivative) const |
calculates weighted input and parameter derivative at the same time More... | |
Public Member Functions inherited from shark::IParameterizable< ModelType::ParameterVectorType > | |
virtual | ~IParameterizable () |
virtual void | setParameterVector (ParameterVectorType const &newParameters) |
Set the parameter vector. More... | |
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... | |
RealVector | m_weight |
Weight of the mean. More... | |
double | m_weightSum |
Total sum of weights. More... | |
std::size_t | m_outputDim |
output dimensionality More... | |
Protected Attributes inherited from shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType > | |
Features | m_features |
Calculates the weighted mean of a set of models.
Definition at line 41 of file MeanModel.h.
typedef ModelBaseType::BatchInputType shark::MeanModel< ModelType >::BatchInputType |
Definition at line 68 of file MeanModel.h.
typedef ModelBaseType::BatchOutputType shark::MeanModel< ModelType >::BatchOutputType |
Definition at line 69 of file MeanModel.h.
typedef ModelBaseType::ParameterVectorType shark::MeanModel< ModelType >::ParameterVectorType |
Definition at line 70 of file MeanModel.h.
|
inline |
Constructor.
Definition at line 72 of file MeanModel.h.
|
inline |
Adds a new model to the ensemble.
model | the new model |
weight | weight of the model. must be > 0 |
Definition at line 135 of file MeanModel.h.
|
inline |
Removes all models from the ensemble.
Definition at line 125 of file MeanModel.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< ModelType::InputType, RealVector, ModelType::ParameterVectorType >.
Definition at line 87 of file MeanModel.h.
Referenced by shark::MeanModel< CARTree< unsigned int > >::eval().
|
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< ModelType::InputType, RealVector, ModelType::ParameterVectorType >.
Definition at line 93 of file MeanModel.h.
|
inline |
Definition at line 142 of file MeanModel.h.
|
inlinevirtual |
Returns the expected shape of the input.
Implements shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType >.
Definition at line 78 of file MeanModel.h.
|
inlinevirtual |
returns the name of the object
Reimplemented from shark::INameable.
Definition at line 74 of file MeanModel.h.
|
inline |
Returns the number of models.
Definition at line 163 of file MeanModel.h.
|
inlinevirtual |
Returns the shape of the output.
Implements shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType >.
Definition at line 82 of file MeanModel.h.
|
inline |
Definition at line 97 of file MeanModel.h.
|
inlinevirtual |
This model does not have any parameters.
Reimplemented from shark::IParameterizable< ModelType::ParameterVectorType >.
Definition at line 103 of file MeanModel.h.
|
inlinevirtual |
From ISerializable, reads a model from an archive.
Reimplemented from shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType >.
Definition at line 111 of file MeanModel.h.
|
inline |
sets the dimensionality of the output
Definition at line 158 of file MeanModel.h.
|
inline |
This model does not have any parameters.
Definition at line 108 of file MeanModel.h.
|
inline |
sets the weight of the i-th model
Definition at line 152 of file MeanModel.h.
|
inline |
Returns the weight of the i-th model.
Definition at line 147 of file MeanModel.h.
Referenced by shark::MeanModel< CARTree< unsigned int > >::addModel().
|
inlinevirtual |
writes a model to an archive
the default implementation just saves the parameters, not the structure!
Reimplemented from shark::AbstractModel< ModelType::InputType, RealVector, ModelType::ParameterVectorType >.
Definition at line 117 of file MeanModel.h.
|
protected |
collection of models.
Definition at line 169 of file MeanModel.h.
Referenced by shark::MeanModel< CARTree< unsigned int > >::addModel(), shark::MeanModel< CARTree< unsigned int > >::clearModels(), shark::MeanModel< CARTree< unsigned int > >::getModel(), shark::MeanModel< CARTree< unsigned int > >::inputShape(), shark::MeanModel< CARTree< unsigned int > >::numberOfModels(), shark::MeanModel< CARTree< unsigned int > >::outputShape(), shark::MeanModel< CARTree< unsigned int > >::read(), and shark::MeanModel< CARTree< unsigned int > >::write().
|
protected |
output dimensionality
Definition at line 178 of file MeanModel.h.
Referenced by shark::MeanModel< CARTree< unsigned int > >::eval(), shark::MeanModel< CARTree< unsigned int > >::outputSize(), shark::MeanModel< CARTree< unsigned int > >::read(), shark::MeanModel< CARTree< unsigned int > >::setOutputSize(), and shark::MeanModel< CARTree< unsigned int > >::write().
|
protected |
Weight of the mean.
Definition at line 172 of file MeanModel.h.
Referenced by shark::MeanModel< CARTree< unsigned int > >::addModel(), shark::MeanModel< CARTree< unsigned int > >::clearModels(), shark::MeanModel< CARTree< unsigned int > >::read(), shark::MeanModel< CARTree< unsigned int > >::setWeight(), shark::MeanModel< CARTree< unsigned int > >::weight(), and shark::MeanModel< CARTree< unsigned int > >::write().
|
protected |
Total sum of weights.
Definition at line 175 of file MeanModel.h.
Referenced by shark::MeanModel< CARTree< unsigned int > >::addModel(), shark::MeanModel< CARTree< unsigned int > >::clearModels(), shark::MeanModel< CARTree< unsigned int > >::read(), shark::MeanModel< CARTree< unsigned int > >::setWeight(), and shark::MeanModel< CARTree< unsigned int > >::write().