shark::AbstractBudgetMaintenanceStrategy< InputType > Class Template Referenceabstract

This is the abstract interface for any budget maintenance strategy. More...

#include <shark/Algorithms/Trainers/Budgeted/AbstractBudgetMaintenanceStrategy.h>

+ Inheritance diagram for shark::AbstractBudgetMaintenanceStrategy< InputType >:

Public Types

typedef KernelExpansion< InputTypeModelType
typedef LabeledData< InputType, unsigned int > DataType
typedef DataType::element_type ElementType

Public Member Functions

 AbstractBudgetMaintenanceStrategy ()
virtual void addToModel (ModelType &model, InputType const &alpha, ElementType const &supportVector)=0
std::string name () const
 return the class name More...

Static Public Member Functions

static void findSmallestVector (ModelType const &model, size_t &minIndex, double &minAlpha)

Detailed Description

template<class InputType>
class shark::AbstractBudgetMaintenanceStrategy< InputType >

This is the abstract interface for any budget maintenance strategy.

To allow for easy exchange of budget maintenance strategies, each of them should derive from this class. The only function it defines is addToModel, which, when implemented, will add a given supportvector and given alphas to the provided model by applying the respective budget maintenance strategy. (Note that not all merging strategies need the alphas, but some do)

Definition at line 62 of file AbstractBudgetMaintenanceStrategy.h.

Member Typedef Documentation

◆ DataType

template<class InputType>
typedef LabeledData<InputType, unsigned int> shark::AbstractBudgetMaintenanceStrategy< InputType >::DataType

Definition at line 67 of file AbstractBudgetMaintenanceStrategy.h.

◆ ElementType

template<class InputType>
typedef DataType::element_type shark::AbstractBudgetMaintenanceStrategy< InputType >::ElementType

Definition at line 68 of file AbstractBudgetMaintenanceStrategy.h.

◆ ModelType

Constructor & Destructor Documentation

◆ AbstractBudgetMaintenanceStrategy()

Member Function Documentation

◆ addToModel()

template<class InputType>
virtual void shark::AbstractBudgetMaintenanceStrategy< InputType >::addToModel ( ModelType model,
InputType const &  alpha,
ElementType const &  supportVector 
pure virtual

this is the main interface, which adds a given supportvector with given alpha coefficients to the model.

[in,out]modelthe model the strategy will work with
[in]alphaalphas for the new budget vector
[in]supportVectorthe vector to add to the model by applying the maintenance strategy

Implemented in shark::MergeBudgetMaintenanceStrategy< RealVector >, shark::RemoveBudgetMaintenanceStrategy< InputType >, and shark::ProjectBudgetMaintenanceStrategy< InputType >.

Referenced by shark::AbstractBudgetMaintenanceStrategy< RealVector >::AbstractBudgetMaintenanceStrategy().

◆ findSmallestVector()

template<class InputType>
static void shark::AbstractBudgetMaintenanceStrategy< InputType >::findSmallestVector ( ModelType const &  model,
size_t &  minIndex,
double &  minAlpha 

this will find the vector with the smallest alpha, measured in 2-norm in the given model. now there is a special case: if there is somewhere a zero coefficient, then obviously this is the smallest element. in this case we just proceed as usual. the caller must decide what to do with such a vector.

note: The model is not allowed to be empty and an exception is thrown in this case.
[in]modelthe model we want to search
[out]minIndexthe index of the vector with smallest coefficient
[out]minAlphathe 2-norm of the alpha coefficient of the found vector

Definition at line 95 of file AbstractBudgetMaintenanceStrategy.h.

Referenced by shark::RemoveBudgetMaintenanceStrategy< InputType >::addToModel().

◆ name()

template<class InputType>
std::string shark::AbstractBudgetMaintenanceStrategy< InputType >::name ( ) const

return the class name

Definition at line 117 of file AbstractBudgetMaintenanceStrategy.h.

Referenced by main().

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