Generic solver skeleton for linear multi-class SVM problems. More...
#include <shark/Algorithms/QP/QpMcLinear.h>
Public Types | |
enum | CoordinateSelectionStrategy { UNIFORM, ACF } |
typedef LabeledData< InputT, unsigned int > | DatasetType |
typedef LabeledData< InputT, unsigned int >::const_element_reference | ElementType |
typedef Batch< InputT >::const_reference | InputReferenceType |
Public Member Functions | |
QpMcLinear (const DatasetType &dataset, std::size_t dim, std::size_t classes, std::size_t strategy=ACF, bool shrinking=false) | |
Constructor. More... | |
RealMatrix | solve (random::rng_type &rng, double C, QpStoppingCondition &stop, QpSolutionProperties *prop=NULL, bool verbose=false) |
Solve the SVM training problem. More... | |
Protected Member Functions | |
void | add_scaled (RealMatrix &w, RealVector const &mu, InputReferenceType x) |
virtual double | calcGradient (RealVector &gradient, RealVector wx, blas::matrix_row< RealMatrix > const &alpha, double C, unsigned int y)=0 |
Compute the gradient from the inner products of the weight vectors with the current sample. More... | |
virtual void | updateWeightVectors (RealMatrix &w, RealVector const &mu, std::size_t index)=0 |
Update the weight vectors (primal variables) after a step on the dual variables. More... | |
virtual double | solveSub (double epsilon, RealVector gradient, double q, double C, unsigned int y, blas::matrix_row< RealMatrix > &alpha, RealVector &mu)=0 |
Solve the sub-problem posed by a single training example. More... | |
Protected Attributes | |
DataView< const DatasetType > | m_data |
view on training data More... | |
RealVector | m_xSquared |
diagonal entries of the quadratic matrix More... | |
std::size_t | m_dim |
input space dimension More... | |
std::size_t | m_classes |
number of classes More... | |
std::size_t | m_strategy |
strategy for coordinate selection More... | |
bool | m_shrinking |
apply shrinking or not? More... | |
Generic solver skeleton for linear multi-class SVM problems.
Definition at line 54 of file QpMcLinear.h.
typedef LabeledData<InputT, unsigned int> shark::QpMcLinear< InputT >::DatasetType |
Definition at line 57 of file QpMcLinear.h.
typedef LabeledData<InputT, unsigned int>::const_element_reference shark::QpMcLinear< InputT >::ElementType |
Definition at line 58 of file QpMcLinear.h.
typedef Batch<InputT>::const_reference shark::QpMcLinear< InputT >::InputReferenceType |
Definition at line 59 of file QpMcLinear.h.
enum shark::QpMcLinear::CoordinateSelectionStrategy |
Enumerator | |
---|---|
UNIFORM | |
ACF |
Definition at line 61 of file QpMcLinear.h.
|
inline |
Constructor.
dataset | training data |
dim | problem dimension |
classes | number of classes in the problem |
strategy | coordinate selection strategy |
shrinking | flag turning shrinking on and off |
Definition at line 73 of file QpMcLinear.h.
References shark::QpMcLinear< InputT >::m_data, shark::QpMcLinear< InputT >::m_dim, shark::QpMcLinear< InputT >::m_xSquared, and SHARK_ASSERT.
|
inlineprotected |
Definition at line 343 of file QpMcLinear.h.
References shark::QpMcLinear< InputT >::m_classes.
Referenced by shark::QpMcLinearWW< InputT >::updateWeightVectors(), shark::QpMcLinearLLW< InputT >::updateWeightVectors(), shark::QpMcLinearATS< InputT >::updateWeightVectors(), shark::QpMcLinearMMR< InputT >::updateWeightVectors(), shark::QpMcLinearCS< InputT >::updateWeightVectors(), shark::QpMcLinearADM< InputT >::updateWeightVectors(), shark::QpMcLinearATM< InputT >::updateWeightVectors(), and shark::QpMcLinearReinforced< InputT >::updateWeightVectors().
|
protectedpure virtual |
Compute the gradient from the inner products of the weight vectors with the current sample.
gradient | gradient vector to be filled in. The vector is correctly sized. |
wx | inner products of weight vectors with the current sample; wx(c) = <w_c, x> |
alpha | variables corresponding to the current sample |
C | upper bound on the variables |
y | label of the current sample |
Implemented in shark::QpMcLinearReinforced< InputT >, shark::QpMcLinearATM< InputT >, shark::QpMcLinearADM< InputT >, shark::QpMcLinearCS< InputT >, shark::QpMcLinearMMR< InputT >, shark::QpMcLinearATS< InputT >, shark::QpMcLinearLLW< InputT >, and shark::QpMcLinearWW< InputT >.
|
inline |
Solve the SVM training problem.
rng | random number generator used by the algorithm |
C | regularization constant of the SVM |
stop | stopping condition(s) |
prop | solution properties |
verbose | if true, the solver prints status information and solution statistics |
Definition at line 103 of file QpMcLinear.h.
References shark::QpMcLinear< InputT >::m_classes, shark::QpMcLinear< InputT >::m_data, shark::QpMcLinear< InputT >::m_dim, shark::QpMcLinear< InputT >::m_strategy, SHARK_ASSERT, shark::Timer::start(), shark::QpMcLinear< InputT >::UNIFORM, and w.
|
protectedpure virtual |
Solve the sub-problem posed by a single training example.
epsilon | accuracy (dual gradient) up to which the sub-problem should be solved |
gradient | gradient of the objective function w.r.t. alpha |
q | squared norm of the current sample |
C | upper bound on the variables |
y | label of the current sample |
alpha | input: initial point; output: (near) optimal point |
mu | step from initial point to final point |
Implemented in shark::QpMcLinearReinforced< InputT >, shark::QpMcLinearATM< InputT >, shark::QpMcLinearADM< InputT >, shark::QpMcLinearCS< InputT >, shark::QpMcLinearMMR< InputT >, shark::QpMcLinearATS< InputT >, shark::QpMcLinearLLW< InputT >, and shark::QpMcLinearWW< InputT >.
|
protectedpure virtual |
Update the weight vectors (primal variables) after a step on the dual variables.
w | matrix of (dense) weight vectors (as rows) |
mu | dual step on the variables corresponding to the current sample |
index | current sample |
Implemented in shark::QpMcLinearReinforced< InputT >, shark::QpMcLinearATM< InputT >, shark::QpMcLinearADM< InputT >, shark::QpMcLinearCS< InputT >, shark::QpMcLinearMMR< InputT >, shark::QpMcLinearATS< InputT >, shark::QpMcLinearLLW< InputT >, and shark::QpMcLinearWW< InputT >.
|
protected |
number of classes
Definition at line 382 of file QpMcLinear.h.
Referenced by shark::QpMcLinear< InputT >::add_scaled(), shark::QpMcLinearLLW< InputT >::calcGradient(), shark::QpMcLinearATS< InputT >::calcGradient(), shark::QpMcLinearMMR< InputT >::calcGradient(), shark::QpMcLinearCS< InputT >::calcGradient(), shark::QpMcLinearADM< InputT >::calcGradient(), shark::QpMcLinearATM< InputT >::calcGradient(), shark::QpMcLinearReinforced< InputT >::calcGradient(), shark::QpMcLinear< InputT >::solve(), shark::QpMcLinearWW< InputT >::solveSub(), shark::QpMcLinearLLW< InputT >::solveSub(), shark::QpMcLinearATS< InputT >::solveSub(), shark::QpMcLinearMMR< InputT >::solveSub(), shark::QpMcLinearCS< InputT >::solveSub(), shark::QpMcLinearADM< InputT >::solveSub(), shark::QpMcLinearATM< InputT >::solveSub(), shark::QpMcLinearReinforced< InputT >::solveSub(), shark::QpMcLinearWW< InputT >::updateWeightVectors(), shark::QpMcLinearLLW< InputT >::updateWeightVectors(), shark::QpMcLinearATS< InputT >::updateWeightVectors(), shark::QpMcLinearMMR< InputT >::updateWeightVectors(), shark::QpMcLinearCS< InputT >::updateWeightVectors(), shark::QpMcLinearADM< InputT >::updateWeightVectors(), shark::QpMcLinearATM< InputT >::updateWeightVectors(), and shark::QpMcLinearReinforced< InputT >::updateWeightVectors().
|
protected |
view on training data
Definition at line 379 of file QpMcLinear.h.
Referenced by shark::QpMcLinear< InputT >::QpMcLinear(), shark::QpMcLinear< InputT >::solve(), shark::QpMcLinearWW< InputT >::updateWeightVectors(), shark::QpMcLinearLLW< InputT >::updateWeightVectors(), shark::QpMcLinearATS< InputT >::updateWeightVectors(), shark::QpMcLinearMMR< InputT >::updateWeightVectors(), shark::QpMcLinearCS< InputT >::updateWeightVectors(), shark::QpMcLinearADM< InputT >::updateWeightVectors(), shark::QpMcLinearATM< InputT >::updateWeightVectors(), and shark::QpMcLinearReinforced< InputT >::updateWeightVectors().
|
protected |
input space dimension
Definition at line 381 of file QpMcLinear.h.
Referenced by shark::QpMcLinear< InputT >::QpMcLinear(), and shark::QpMcLinear< InputT >::solve().
|
protected |
apply shrinking or not?
Definition at line 384 of file QpMcLinear.h.
|
protected |
strategy for coordinate selection
Definition at line 383 of file QpMcLinear.h.
Referenced by shark::QpMcLinear< InputT >::solve().
|
protected |
diagonal entries of the quadratic matrix
Definition at line 380 of file QpMcLinear.h.
Referenced by shark::QpMcLinear< InputT >::QpMcLinear().