Super class of all kernelized (non-linear) SVM trainers. More...
#include <shark/Algorithms/Trainers/AbstractSvmTrainer.h>
Inheritance diagram for shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >:Public Types | |
| typedef AbstractKernelFunction< InputType > | KernelType |
Public Types inherited from shark::AbstractTrainer< Model, LabelTypeT > | |
| typedef Model | ModelType |
| typedef ModelType::InputType | InputType |
| typedef LabelTypeT | LabelType |
| typedef LabeledData< InputType, LabelType > | DatasetType |
Public Types inherited from shark::IParameterizable< VectorType > | |
| typedef VectorType | ParameterVectorType |
Public Member Functions | |
| AbstractSvmTrainer (KernelType *kernel, double C, bool offset, bool unconstrained=false) | |
| AbstractSvmTrainer (KernelType *kernel, double negativeC, double positiveC, bool offset, bool unconstrained=false) | |
| double | C () const |
| Return the value of the regularization parameter C. | |
| void | setC (double C) |
| Set the value of the regularization parameter C. | |
| RealVector const & | regularizationParameters () const |
| void | setRegularizationParameters (RealVector const ®ularizers) |
| Set the value of the regularization parameter C. | |
| KernelType * | kernel () |
| KernelType const * | kernel () const |
| void | setKernel (KernelType *kernel) |
| bool | isUnconstrained () const |
| bool | trainOffset () const |
| std::size_t | cacheSize () const |
| void | setCacheSize (std::size_t size) |
| RealVector | parameterVector () const |
| get the hyper-parameter vector | |
| void | setParameterVector (RealVector const &newParameters) |
| set the vector of hyper-parameters | |
| size_t | numberOfParameters () const |
| return the number of hyper-parameters | |
Public Member Functions inherited from shark::AbstractTrainer< Model, LabelTypeT > | |
| virtual void | train (ModelType &model, DatasetType const &dataset)=0 |
| Core of the Trainer interface. | |
Public Member Functions inherited from shark::INameable | |
| virtual | ~INameable () |
| virtual std::string | name () const |
| returns the name of the object | |
Public Member Functions inherited from shark::ISerializable | |
| virtual | ~ISerializable () |
| Virtual d'tor. | |
| virtual void | read (InArchive &archive) |
| Read the component from the supplied archive. | |
| virtual void | write (OutArchive &archive) const |
| Write the component to the supplied archive. | |
| 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 () | |
Public Member Functions inherited from shark::QpConfig | |
| QpConfig (bool precomputedFlag=false, bool sparsifyFlag=true) | |
| Constructor. | |
| QpStoppingCondition & | stoppingCondition () |
| Read/write access to the stopping condition. | |
| QpStoppingCondition const & | stoppingCondition () const |
| Read access to the stopping condition. | |
| QpSolutionProperties & | solutionProperties () |
| Access to the solution properties. | |
| bool & | precomputeKernel () |
| Flag for using a precomputed kernel matrix. | |
| bool const & | precomputeKernel () const |
| Flag for using a precomputed kernel matrix. | |
| bool & | sparsify () |
| Flag for sparsifying the model after training. | |
| bool const & | sparsify () const |
| Flag for sparsifying the model after training. | |
| bool & | shrinking () |
| Flag for shrinking in the decomposition solver. | |
| bool const & | shrinking () const |
| Flag for shrinking in the decomposition solver. | |
| bool & | s2do () |
| Flag for S2DO (instead of SMO) | |
| bool const & | s2do () const |
| Flag for S2DO (instead of SMO) | |
| unsigned int & | verbosity () |
| Verbosity level of the solver. | |
| unsigned int const & | verbosity () const |
| Verbosity level of the solver. | |
| unsigned long long const & | accessCount () const |
| Number of kernel accesses. | |
| void | setMinAccuracy (double a) |
| void | setMaxIterations (unsigned long long i) |
| void | setTargetValue (double v) |
| void | setMaxSeconds (double s) |
Public Member Functions inherited from shark::IParameterizable< VectorType > | |
| virtual | ~IParameterizable () |
Protected Attributes | |
| KernelType * | m_kernel |
| RealVector | m_regularizers |
| Vector of regularization parameters. | |
| bool | m_trainOffset |
| bool | m_unconstrained |
| Is log(C) stored internally as a parameter instead of C? If yes, then we get rid of the constraint C > 0 on the level of the parameter interface. | |
| std::size_t | m_cacheSize |
| Number of values in the kernel cache. The size of the cache in bytes is the size of one entry (4 for float, 8 for double) times this number. | |
Protected Attributes inherited from shark::QpConfig | |
| QpStoppingCondition | m_stoppingcondition |
| conditions for when to stop the QP solver | |
| QpSolutionProperties | m_solutionproperties |
| properties of the approximate solution found by the solver | |
| bool | m_precomputedKernelMatrix |
| should the solver use a precomputed kernel matrix? | |
| bool | m_sparsify |
| should the trainer sparsify the model after training? | |
| bool | m_shrinking |
| should shrinking be used? | |
| bool | m_s2do |
| should S2DO be used instead of SMO? | |
| unsigned int | m_verbosity |
| verbosity level (currently unused) | |
| unsigned long long | m_accessCount |
| kernel access count | |
Super class of all kernelized (non-linear) SVM trainers.
Definition at line 185 of file AbstractSvmTrainer.h.
| typedef AbstractKernelFunction<InputType> shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::KernelType |
Definition at line 189 of file AbstractSvmTrainer.h.
|
inline |
Constructor
| kernel | kernel function to use for training and prediction |
| C | regularization parameter - always the 'true' value of C, even when unconstrained is set |
| offset | train svm with offset - this is not supported for all SVM solvers. |
| unconstrained | when a C-value is given via setParameter, should it be piped through the exp-function before using it in the solver? |
Definition at line 196 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::C(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::kernel(), and SHARK_RUNTIME_CHECK.
|
inline |
Constructor featuring two regularization parameters
| kernel | kernel function to use for training and prediction |
| negativeC | regularization parameter of the negative class (label 0) |
| positiveC | regularization parameter of the positive class (label 1) |
| offset | train svm with offset - this is not supported for all SVM solvers. |
| unconstrained | when a C-value is given via setParameter, should it be piped through the exp-function before using it in the solver? |
Definition at line 213 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::kernel(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, and SHARK_RUNTIME_CHECK.
|
inline |
Return the value of the regularization parameter C.
Definition at line 229 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, and SIZE_CHECK.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::AbstractSvmTrainer(), main(), run_one_trial(), and shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setC().
|
inline |
Definition at line 266 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_cacheSize.
|
inline |
Definition at line 260 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_unconstrained.
|
inline |
Definition at line 251 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_kernel.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::AbstractSvmTrainer(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::AbstractSvmTrainer(), shark::CSvmDerivative< InputType, CacheType >::CSvmDerivative(), and shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setKernel().
|
inline |
Definition at line 253 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_kernel.
|
inlinevirtual |
return the number of hyper-parameters
Reimplemented from shark::IParameterizable< VectorType >.
Reimplemented in shark::EpsilonSvmTrainer< InputType, CacheType >.
Definition at line 290 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_kernel, shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, and shark::IParameterizable< VectorType >::numberOfParameters().
|
inlinevirtual |
get the hyper-parameter vector
Reimplemented from shark::IParameterizable< VectorType >.
Reimplemented in shark::EpsilonSvmTrainer< InputType, CacheType >.
Definition at line 272 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_kernel, shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_unconstrained, and shark::IParameterizable< VectorType >::parameterVector().
Referenced by run_one_trial().
|
inline |
Definition at line 240 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers.
|
inline |
Set the value of the regularization parameter C.
Definition at line 235 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::C(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, and SHARK_RUNTIME_CHECK.
|
inline |
Definition at line 268 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_cacheSize.
Referenced by main().
|
inline |
Definition at line 255 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::kernel(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_kernel, and SHARK_RUNTIME_CHECK.
|
inlinevirtual |
set the vector of hyper-parameters
Reimplemented from shark::IParameterizable< VectorType >.
Reimplemented in shark::EpsilonSvmTrainer< InputType, CacheType >.
Definition at line 280 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_kernel, shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_unconstrained, shark::IParameterizable< VectorType >::numberOfParameters(), shark::IParameterizable< VectorType >::setParameterVector(), and SHARK_ASSERT.
Referenced by main(), and run_one_trial().
|
inline |
Set the value of the regularization parameter C.
Definition at line 246 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_regularizers, and SHARK_RUNTIME_CHECK.
|
inline |
Definition at line 263 of file AbstractSvmTrainer.h.
References shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::m_trainOffset.
Referenced by main().
|
protected |
Number of values in the kernel cache. The size of the cache in bytes is the size of one entry (4 for float, 8 for double) times this number.
Definition at line 305 of file AbstractSvmTrainer.h.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::cacheSize(), and shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setCacheSize().
|
protected |
Kernel object.
Definition at line 295 of file AbstractSvmTrainer.h.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::kernel(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::kernel(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::numberOfParameters(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::parameterVector(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setKernel(), and shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setParameterVector().
|
protected |
Vector of regularization parameters.
If the size of the vector is 1 there is only one regularization parameter for all classes, else there must be one for every class in the dataset. The exact meaning depends on the sub-class, but the value is always positive, and higher implies a less regular solution.
Definition at line 302 of file AbstractSvmTrainer.h.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::AbstractSvmTrainer(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::C(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::numberOfParameters(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::parameterVector(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::regularizationParameters(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setC(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setParameterVector(), and shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setRegularizationParameters().
|
protected |
Definition at line 303 of file AbstractSvmTrainer.h.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::trainOffset().
|
protected |
Is log(C) stored internally as a parameter instead of C? If yes, then we get rid of the constraint C > 0 on the level of the parameter interface.
Definition at line 304 of file AbstractSvmTrainer.h.
Referenced by shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::isUnconstrained(), shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::parameterVector(), and shark::AbstractSvmTrainer< InputType, LabelType, Model, Trainer >::setParameterVector().