Training of a regularization network. More...
#include <shark/Algorithms/Trainers/RegularizationNetworkTrainer.h>
Public Types | |
typedef AbstractModel< InputType, RealVector > | ModelType |
typedef AbstractKernelFunction< InputType > | KernelType |
Public Types inherited from shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > > | |
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<> | |
typedef RealVector | ParameterVectorType |
Public Member Functions | |
RegularizationNetworkTrainer (KernelType *kernel, double betaInv, bool unconstrained=false) | |
std::string | name () const |
From INameable: return the class name. More... | |
double | noiseVariance () const |
Returns the assumed noise variance (i.e., 1/C) More... | |
void | setNoiseVariance (double betaInv) |
Sets the assumed noise variance (i.e., 1/C) More... | |
double | precision () const |
Returns the precision (i.e., C), the inverse of the assumed noise variance. More... | |
void | setPrecision (double beta) |
Sets the precision (i.e., C), the inverse of the assumed noise variance. More... | |
void | train (KernelExpansion< InputType > &svm, const LabeledData< InputType, RealVector > &dataset) |
Public Member Functions inherited from shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > > | |
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. More... | |
void | setC (double C) |
Set the value of the regularization parameter C. More... | |
RealVector const & | regularizationParameters () const |
void | setRegularizationParameters (RealVector const ®ularizers) |
Set the value of the regularization parameter C. More... | |
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 More... | |
void | setParameterVector (RealVector const &newParameters) |
set the vector of hyper-parameters More... | |
size_t | numberOfParameters () const |
return the number of hyper-parameters More... | |
Public Member Functions inherited from shark::AbstractTrainer< Model, LabelTypeT > | |
virtual void | train (ModelType &model, DatasetType const &dataset)=0 |
Core of the Trainer interface. More... | |
Public Member Functions inherited from shark::INameable | |
virtual | ~INameable () |
Public Member Functions inherited from shark::ISerializable | |
virtual | ~ISerializable () |
Virtual d'tor. More... | |
virtual void | read (InArchive &archive) |
Read the component from the supplied archive. More... | |
virtual void | write (OutArchive &archive) const |
Write the component to the supplied archive. 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 () | |
Public Member Functions inherited from shark::QpConfig | |
QpConfig (bool precomputedFlag=false, bool sparsifyFlag=true) | |
Constructor. More... | |
QpStoppingCondition & | stoppingCondition () |
Read/write access to the stopping condition. More... | |
QpStoppingCondition const & | stoppingCondition () const |
Read access to the stopping condition. More... | |
QpSolutionProperties & | solutionProperties () |
Access to the solution properties. More... | |
bool & | precomputeKernel () |
Flag for using a precomputed kernel matrix. More... | |
bool const & | precomputeKernel () const |
Flag for using a precomputed kernel matrix. More... | |
bool & | sparsify () |
Flag for sparsifying the model after training. More... | |
bool const & | sparsify () const |
Flag for sparsifying the model after training. More... | |
bool & | shrinking () |
Flag for shrinking in the decomposition solver. More... | |
bool const & | shrinking () const |
Flag for shrinking in the decomposition solver. More... | |
bool & | s2do () |
Flag for S2DO (instead of SMO) More... | |
bool const & | s2do () const |
Flag for S2DO (instead of SMO) More... | |
unsigned int & | verbosity () |
Verbosity level of the solver. More... | |
unsigned int const & | verbosity () const |
Verbosity level of the solver. More... | |
unsigned long long const & | accessCount () const |
Number of kernel accesses. More... | |
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<> | |
virtual | ~IParameterizable () |
Additional Inherited Members | |
Protected Attributes inherited from shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > > | |
KernelType * | m_kernel |
RealVector | m_regularizers |
Vector of regularization parameters. More... | |
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. More... | |
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. More... | |
Protected Attributes inherited from shark::QpConfig | |
QpStoppingCondition | m_stoppingcondition |
conditions for when to stop the QP solver More... | |
QpSolutionProperties | m_solutionproperties |
properties of the approximate solution found by the solver More... | |
bool | m_precomputedKernelMatrix |
should the solver use a precomputed kernel matrix? More... | |
bool | m_sparsify |
should the trainer sparsify the model after training? More... | |
bool | m_shrinking |
should shrinking be used? More... | |
bool | m_s2do |
should S2DO be used instead of SMO? More... | |
unsigned int | m_verbosity |
verbosity level (currently unused) More... | |
unsigned long long | m_accessCount |
kernel access count More... | |
Training of a regularization network.
A regularization network is a kernel-based model for regression problems. Given are data tuples \( (x_i, y_i) \) with x-component denoting input and y-component denoting a real-valued label (see the tutorial on label conventions; the implementation uses RealVector), a kernel function k(x, x') and a regularization constant \( C > 0\). Let H denote the kernel induced reproducing kernel Hilbert space of k, and let \( \phi \) denote the corresponding feature map. Then the SVM regression function is of the form
\[ f(x) = \langle w, \phi(x) \rangle + b \]
with coefficients w and b given by the (primal) optimization problem
\[ \min \frac{1}{2} \|w\|^2 + C \sum_i L(y_i, f(x_i)), \]
where the simple quadratic loss is employed:
\[ L(y, f(x)) = (y - f(x))^2 \]
Regularization networks can be interpreted as a special type of support vector machine (for regression, with squared loss, and thus with non-sparse weights).
Training a regularization network is identical to training a Gaussian process for regression. The parameter \( C \) then corresponds precision of the noise (denoted by \( \beta \) in Bishop's textbook). The precision is the inverse of the variance of the noise. The variance of the noise is denoted by \( \sigma_n^2 \) in the textbook by Rasmussen and Williams. Accordingly, \( C = 1/\sigma_n^2 \).
Definition at line 86 of file RegularizationNetworkTrainer.h.
typedef AbstractKernelFunction<InputType> shark::RegularizationNetworkTrainer< InputType >::KernelType |
Definition at line 90 of file RegularizationNetworkTrainer.h.
typedef AbstractModel<InputType, RealVector> shark::RegularizationNetworkTrainer< InputType >::ModelType |
Definition at line 89 of file RegularizationNetworkTrainer.h.
|
inline |
kernel | Kernel |
betaInv | Inverse precision, equal to assumed noise variance, equal to inverse regularization parameter C |
unconstrained | Indicates exponential encoding of the regularization parameter |
Definition at line 96 of file RegularizationNetworkTrainer.h.
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
Definition at line 101 of file RegularizationNetworkTrainer.h.
|
inline |
Returns the assumed noise variance (i.e., 1/C)
Definition at line 105 of file RegularizationNetworkTrainer.h.
References shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > >::C().
Referenced by shark::RegularizationNetworkTrainer< InputType >::train().
|
inline |
Returns the precision (i.e., C), the inverse of the assumed noise variance.
Definition at line 112 of file RegularizationNetworkTrainer.h.
References shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > >::C().
|
inline |
Sets the assumed noise variance (i.e., 1/C)
Definition at line 108 of file RegularizationNetworkTrainer.h.
References shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > >::C().
|
inline |
Sets the precision (i.e., C), the inverse of the assumed noise variance.
Definition at line 115 of file RegularizationNetworkTrainer.h.
References beta, and shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > >::C().
|
inline |
Definition at line 118 of file RegularizationNetworkTrainer.h.
References shark::calculateRegularizedKernelMatrix(), shark::LabeledData< InputT, LabelT >::inputs(), shark::labelDimension(), shark::LabeledData< InputT, LabelT >::labels(), shark::AbstractSvmTrainer< InputType, RealVector, KernelExpansion< InputType > >::m_kernel, shark::mean(), shark::RegularizationNetworkTrainer< InputType >::noiseVariance(), and shark::KernelExpansion< InputType >::setStructure().