shark::ModifiedKernelMatrix< InputType, CacheType > Class Template Reference

Modified Kernel Gram matrix. More...

#include <shark/LinAlg/ModifiedKernelMatrix.h>

Public Types

typedef Matrix::QpFloatType QpFloatType
 

Public Member Functions

 ModifiedKernelMatrix (AbstractKernelFunction< InputType > const &kernelfunction, LabeledData< InputType, unsigned int > const &data, QpFloatType modifierEq, QpFloatType modifierNe)
 
QpFloatType operator() (std::size_t i, std::size_t j) const
 return a single matrix entry More...
 
QpFloatType entry (std::size_t i, std::size_t j) const
 return a single matrix entry More...
 
void row (std::size_t i, std::size_t start, std::size_t end, QpFloatType *storage) const
 Computes the i-th row of the kernel matrix. More...
 
template<class M >
void matrix (blas::matrix_expression< M, blas::cpu_tag > &storage) const
 Computes the kernel-matrix. More...
 
void flipColumnsAndRows (std::size_t i, std::size_t j)
 swap two variables More...
 
std::size_t size () const
 return the size of the quadratic matrix More...
 
unsigned long long getAccessCount () const
 query the kernel access counter More...
 
void resetAccessCount ()
 reset the kernel access counter More...
 

Protected Attributes

Matrix m_matrix
 Kernel matrix which computes the basic entries. More...
 
std::vector< unsigned int > m_labels
 
QpFloatType m_modifierEq
 modifier in case the labels are equal More...
 
QpFloatType m_modifierNe
 modifier in case the labels differ More...
 

Detailed Description

template<class InputType, class CacheType>
class shark::ModifiedKernelMatrix< InputType, CacheType >

Modified Kernel Gram matrix.

The ModifiedKernelMatrix represents the kernel matrix multiplied element-wise with a factor depending on the labels of the training examples. This is useful for the MCMMR method (multi-class maximum margin regression).

Definition at line 60 of file ModifiedKernelMatrix.h.

Member Typedef Documentation

◆ QpFloatType

template<class InputType , class CacheType >
typedef Matrix::QpFloatType shark::ModifiedKernelMatrix< InputType, CacheType >::QpFloatType

Definition at line 65 of file ModifiedKernelMatrix.h.

Constructor & Destructor Documentation

◆ ModifiedKernelMatrix()

template<class InputType , class CacheType >
shark::ModifiedKernelMatrix< InputType, CacheType >::ModifiedKernelMatrix ( AbstractKernelFunction< InputType > const &  kernelfunction,
LabeledData< InputType, unsigned int > const &  data,
QpFloatType  modifierEq,
QpFloatType  modifierNe 
)
inline

Constructor

Parameters
kernelfunctionkernel function
datadata to evaluate the kernel function
modifierEqmultiplier for same-class labels
modifierNemultiplier for different-class kernels

Definition at line 72 of file ModifiedKernelMatrix.h.

References shark::LabeledData< InputT, LabelT >::element(), and shark::ModifiedKernelMatrix< InputType, CacheType >::m_labels.

Member Function Documentation

◆ entry()

◆ flipColumnsAndRows()

template<class InputType , class CacheType >
void shark::ModifiedKernelMatrix< InputType, CacheType >::flipColumnsAndRows ( std::size_t  i,
std::size_t  j 
)
inline

◆ getAccessCount()

template<class InputType , class CacheType >
unsigned long long shark::ModifiedKernelMatrix< InputType, CacheType >::getAccessCount ( ) const
inline

◆ matrix()

◆ operator()()

template<class InputType , class CacheType >
QpFloatType shark::ModifiedKernelMatrix< InputType, CacheType >::operator() ( std::size_t  i,
std::size_t  j 
) const
inline

return a single matrix entry

Definition at line 87 of file ModifiedKernelMatrix.h.

References shark::ModifiedKernelMatrix< InputType, CacheType >::entry().

◆ resetAccessCount()

template<class InputType , class CacheType >
void shark::ModifiedKernelMatrix< InputType, CacheType >::resetAccessCount ( )
inline

◆ row()

template<class InputType , class CacheType >
void shark::ModifiedKernelMatrix< InputType, CacheType >::row ( std::size_t  i,
std::size_t  start,
std::size_t  end,
QpFloatType storage 
) const
inline

Computes the i-th row of the kernel matrix.

The entries start,...,end of the i-th row are computed and stored in storage. There must be enough room for this operation preallocated.

Definition at line 102 of file ModifiedKernelMatrix.h.

References shark::ModifiedKernelMatrix< InputType, CacheType >::m_labels, shark::ModifiedKernelMatrix< InputType, CacheType >::m_matrix, shark::ModifiedKernelMatrix< InputType, CacheType >::m_modifierEq, shark::ModifiedKernelMatrix< InputType, CacheType >::m_modifierNe, and shark::KernelMatrix< InputType, CacheType >::row().

◆ size()

template<class InputType , class CacheType >
std::size_t shark::ModifiedKernelMatrix< InputType, CacheType >::size ( ) const
inline

Member Data Documentation

◆ m_labels

◆ m_matrix

◆ m_modifierEq

template<class InputType , class CacheType >
QpFloatType shark::ModifiedKernelMatrix< InputType, CacheType >::m_modifierEq
protected

◆ m_modifierNe

template<class InputType , class CacheType >
QpFloatType shark::ModifiedKernelMatrix< InputType, CacheType >::m_modifierNe
protected

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