公有成员 | 保护成员 | 静态保护成员 | 保护属性 | 友元

CKernel类参考


详细描述

The Kernel base class.

Non-mathematically spoken, a kernel is a function that given two input objects ${\bf x}$ and ${\bf x'}$ returns a score describing the similarity of the vectors. The score should be larger when the objects are more similar.

It can be defined as

\[ k({\bf x},{\bf x'})= \Phi_k({\bf x})\cdot \Phi_k({\bf x'}) \]

where $\Phi$ maps the objects into some potentially high dimensional feature space.

Apart from the input features, the base kernel takes only one argument (the size of the kernel cache) that is used to efficiently train kernel-machines like e.g. SVMs.

In case you would like to define your own kernel, you only have to define a new compute() function (and the kernel name via get_name() and the kernel type get_kernel_type()). A good example to look at is the GaussianKernel.

在文件Kernel.h147行定义。

继承图,类CKernel
Inheritance graph
[图例]

所有成员的列表。

公有成员

 CKernel ()
 CKernel (int32_t size)
 CKernel (CFeatures *l, CFeatures *r, int32_t size)
virtual ~CKernel ()
float64_t kernel (int32_t idx_a, int32_t idx_b)
void get_kernel_matrix (float64_t **dst, int32_t *m, int32_t *n)
template<class T >
T * get_kernel_matrix (int32_t &m, int32_t &n, T *target)
virtual bool init (CFeatures *lhs, CFeatures *rhs)
virtual bool set_normalizer (CKernelNormalizer *normalizer)
virtual CKernelNormalizerget_normalizer ()
virtual bool init_normalizer ()
virtual void cleanup ()
void load (CFile *loader)
void save (CFile *writer)
CFeaturesget_lhs ()
CFeaturesget_rhs ()
virtual int32_t get_num_vec_lhs ()
virtual int32_t get_num_vec_rhs ()
virtual bool has_features ()
bool lhs_equals_rhs ()
virtual void remove_lhs_and_rhs ()
virtual void remove_lhs ()
virtual void remove_rhs ()
 takes all necessary steps if the rhs is removed from kernel
virtual EKernelType get_kernel_type ()=0
virtual EFeatureType get_feature_type ()=0
virtual EFeatureClass get_feature_class ()=0
void set_cache_size (int32_t size)
int32_t get_cache_size ()
void list_kernel ()
bool has_property (EKernelProperty p)
virtual void clear_normal ()
virtual void add_to_normal (int32_t vector_idx, float64_t weight)
EOptimizationType get_optimization_type ()
virtual void set_optimization_type (EOptimizationType t)
bool get_is_initialized ()
virtual bool init_optimization (int32_t count, int32_t *IDX, float64_t *weights)
virtual bool delete_optimization ()
bool init_optimization_svm (CSVM *svm)
virtual float64_t compute_optimized (int32_t vector_idx)
virtual void compute_batch (int32_t num_vec, int32_t *vec_idx, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, float64_t factor=1.0)
float64_t get_combined_kernel_weight ()
void set_combined_kernel_weight (float64_t nw)
virtual int32_t get_num_subkernels ()
virtual void compute_by_subkernel (int32_t vector_idx, float64_t *subkernel_contrib)
virtual const float64_tget_subkernel_weights (int32_t &num_weights)
virtual void set_subkernel_weights (float64_t *weights, int32_t num_weights)

保护成员

void set_property (EKernelProperty p)
void unset_property (EKernelProperty p)
void set_is_initialized (bool p_init)
virtual float64_t compute (int32_t x, int32_t y)=0
int32_t compute_row_start (int64_t offs, int32_t n, bool symmetric)

静态保护成员

template<class T >
static void * get_kernel_matrix_helper (void *p)

保护属性

int32_t cache_size
 cache_size in MB
KERNELCACHE_ELEMkernel_matrix
CFeatureslhs
 feature vectors to occur on left hand side
CFeaturesrhs
 feature vectors to occur on right hand side
int32_t num_lhs
 number of feature vectors on left hand side
int32_t num_rhs
 number of feature vectors on right hand side
float64_t combined_kernel_weight
bool optimization_initialized
EOptimizationType opt_type
uint64_t properties
CKernelNormalizernormalizer

友元

class CVarianceKernelNormalizer
class CSqrtDiagKernelNormalizer
class CAvgDiagKernelNormalizer
class CRidgeKernelNormalizer
class CFirstElementKernelNormalizer
class CMultitaskKernelNormalizer
class CMultitaskKernelMklNormalizer
class CMultitaskKernelMaskNormalizer
class CMultitaskKernelMaskPairNormalizer
class CTanimotoKernelNormalizer
class CDiceKernelNormalizer

构造及析构函数文档

CKernel (  )

default constructor

在文件Kernel.cpp44行定义。

CKernel ( int32_t  size )

constructor

参数:
sizecache size

在文件Kernel.cpp56行定义。

CKernel ( CFeatures l,
CFeatures r,
int32_t  size 
)

constructor

参数:
lfeatures for left-hand side
rfeatures for right-hand side
sizecache size

在文件Kernel.cpp74行定义。

~CKernel (  ) [virtual]

在文件Kernel.cpp91行定义。


成员函数文档

void add_to_normal ( int32_t  vector_idx,
float64_t  weight 
) [virtual]
void cleanup (  ) [virtual]
void clear_normal (  ) [virtual]

for optimizable kernels, i.e. kernels where the weight vector can be computed explicitly (if it fits into memory)

CCombinedKernelCCommUlongStringKernelCCommWordStringKernelCLinearByteKernelCLinearKernelCLinearStringKernelCLinearWordKernelCSparseLinearKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp438行定义。

virtual float64_t compute ( int32_t  x,
int32_t  y 
) [protected, pure virtual]
void compute_batch ( int32_t  num_vec,
int32_t *  vec_idx,
float64_t target,
int32_t  num_suppvec,
int32_t *  IDX,
float64_t alphas,
float64_t  factor = 1.0 
) [virtual]

computes output for a batch of examples in an optimized fashion (favorable if kernel supports it, i.e. has KP_BATCHEVALUATION. to the outputvector target (of length num_vec elements) the output for the examples enumerated in vec_idx are added. therefore make sure that it is initialized with ZERO. the following num_suppvec, IDX, alphas arguments are the number of support vectors, their indices and weights

CCombinedKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp426行定义。

void compute_by_subkernel ( int32_t  vector_idx,
float64_t subkernel_contrib 
) [virtual]

compute by subkernel

参数:
vector_idxindex
subkernel_contribsubkernel contribution

CCombinedKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp448行定义。

float64_t compute_optimized ( int32_t  vector_idx ) [virtual]
int32_t compute_row_start ( int64_t  offs,
int32_t  n,
bool  symmetric 
) [protected]

compute row start offset for parallel kernel matrix computation

参数:
offsoffset
nnumber of columns
symmetricwhether matrix is symmetric

在文件Kernel.h628行定义。

bool delete_optimization (  ) [virtual]
int32_t get_cache_size (  )

return the size of the kernel cache

返回:
size of kernel cache

在文件Kernel.h457行定义。

float64_t get_combined_kernel_weight (  )

get combined kernel weight

返回:
combined kernel weight

在文件Kernel.h548行定义。

virtual EFeatureClass get_feature_class (  ) [pure virtual]
virtual EFeatureType get_feature_type (  ) [pure virtual]
bool get_is_initialized (  )

check if optimization is initialized

返回:
if optimization is initialized

在文件Kernel.h499行定义。

void get_kernel_matrix ( float64_t **  dst,
int32_t *  m,
int32_t *  n 
)

get kernel matrix

参数:
dstdestination where matrix will be stored
mdimension m of matrix
ndimension n of matrix

在文件Kernel.cpp102行定义。

T* get_kernel_matrix ( int32_t &  m,
int32_t &  n,
T *  target 
)

get kernel matrix real

参数:
mdimension m of matrix
ndimension n of matrix
targetthe kernel matrix
返回:
the kernel matrix

在文件Kernel.h219行定义。

static void* get_kernel_matrix_helper ( void *  p ) [static, protected]

helper for computing the kernel matrix in a parallel way

参数:
pthread parameters

在文件Kernel.h645行定义。

virtual EKernelType get_kernel_type (  ) [pure virtual]
CFeatures* get_lhs (  )

get left-hand side of features used in kernel

返回:
features of left-hand side

在文件Kernel.h365行定义。

CKernelNormalizer * get_normalizer (  ) [virtual]

obtain the current kernel normalizer

返回:
the kernel normalizer

在文件Kernel.cpp173行定义。

int32_t get_num_subkernels (  ) [virtual]

get number of subkernels

返回:
number of subkernels

CCombinedKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp443行定义。

virtual int32_t get_num_vec_lhs (  ) [virtual]

get number of vectors of lhs features

返回:
number of vectors of left-hand side

CCustomKernel重载。

在文件Kernel.h377行定义。

virtual int32_t get_num_vec_rhs (  ) [virtual]

get number of vectors of rhs features

返回:
number of vectors of right-hand side

CCustomKernel重载。

在文件Kernel.h386行定义。

EOptimizationType get_optimization_type (  )

get optimization type

返回:
optimization type

在文件Kernel.h487行定义。

CFeatures* get_rhs (  )

get right-hand side of features used in kernel

返回:
features of right-hand side

在文件Kernel.h371行定义。

const float64_t * get_subkernel_weights ( int32_t &  num_weights ) [virtual]

get subkernel weights

参数:
num_weightsnumber of weights will be stored here
返回:
subkernel weights

CCombinedKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp454行定义。

virtual bool has_features (  ) [virtual]

test whether features have been assigned to lhs and rhs

返回:
true if features are assigned

CCombinedKernelCCustomKernel重载。

在文件Kernel.h395行定义。

bool has_property ( EKernelProperty  p )

check if kernel has given property

参数:
pkernel property
返回:
if kernel has given property

在文件Kernel.h469行定义。

bool init ( CFeatures lhs,
CFeatures rhs 
) [virtual]

initialize kernel e.g. setup lhs/rhs of kernel, precompute normalization constants etc. make sure to check that your kernel can deal with the supplied features (!)

参数:
lhsfeatures for left-hand side
rhsfeatures for right-hand side
返回:
if init was successful

CAUCKernelCChi2KernelCCombinedKernelCCommUlongStringKernelCCommWordStringKernelCConstKernelCCustomKernelCDistanceKernelCFixedDegreeStringKernelCGaussianKernelCGaussianMatchStringKernelCGaussianShortRealKernelCHistogramWordStringKernelCLinearByteKernelCLinearKernelCLinearStringKernelCLinearWordKernelCLocalAlignmentStringKernelCLocalityImprovedStringKernelCMatchWordStringKernelCOligoStringKernelCPolyKernelCPolyMatchStringKernelCPolyMatchWordStringKernelCPyramidChi2CRegulatoryModulesStringKernelCSalzbergWordStringKernelCSigmoidKernelCSimpleKernel< ST >CSimpleLocalityImprovedStringKernelCSNPStringKernelCSparseGaussianKernelCSparseKernel< ST >CSparseLinearKernelCSparsePolyKernelCSpectrumMismatchRBFKernelCSpectrumRBFKernelCStringKernel< ST >CTensorProductPairKernelCWeightedCommWordStringKernelCWeightedDegreePositionStringKernelCWeightedDegreeRBFKernelCWeightedDegreeStringKernelCSimpleKernel< float64_t >CSimpleKernel< float32_t >CSimpleKernel< int32_t >CSimpleKernel< uint8_t >CSimpleKernel< uint16_t >CSparseKernel< float64_t >CStringKernel< char >CStringKernel< uint16_t >CStringKernel< uint64_t >重载。

在文件Kernel.cpp131行定义。

bool init_normalizer (  ) [virtual]

initialize the current kernel normalizer

返回:
if init was successful

在文件Kernel.cpp179行定义。

bool init_optimization ( int32_t  count,
int32_t *  IDX,
float64_t weights 
) [virtual]

initialize optimization

参数:
countcount
IDXindex
weightsweights
返回:
if initializing was successful

CCombinedKernelCCommUlongStringKernelCCommWordStringKernelCLinearByteKernelCLinearKernelCLinearStringKernelCLinearWordKernelCSparseLinearKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp407行定义。

bool init_optimization_svm ( CSVM svm )

initialize optimization

参数:
svmsvm model
返回:
if initializing was successful

在文件Kernel.cpp467行定义。

float64_t kernel ( int32_t  idx_a,
int32_t  idx_b 
)

get kernel function for lhs feature vector a and rhs feature vector b

参数:
idx_aindex of feature vector a
idx_bindex of feature vector b
返回:
computed kernel function

在文件Kernel.h192行定义。

bool lhs_equals_rhs (  )

test whether features on lhs and rhs are the same

返回:
true if features are the same

在文件Kernel.h404行定义。

void list_kernel (  )

list kernel

在文件Kernel.cpp240行定义。

void load ( CFile loader )

load the kernel matrix

参数:
loaderFile object via which to load data

在文件Kernel.cpp191行定义。

void remove_lhs (  ) [virtual]
void remove_lhs_and_rhs (  ) [virtual]

remove lhs and rhs from kernel

CCombinedKernel重载。

在文件Kernel.cpp203行定义。

void remove_rhs (  ) [virtual]

takes all necessary steps if the rhs is removed from kernel

remove rhs from kernel

CCombinedKernelCCommUlongStringKernel重载。

在文件Kernel.cpp229行定义。

void save ( CFile writer )

save kernel matrix

参数:
writerFile object via which to save data

在文件Kernel.cpp195行定义。

void set_cache_size ( int32_t  size )

set the size of the kernel cache

参数:
sizeof kernel cache

在文件Kernel.h447行定义。

void set_combined_kernel_weight ( float64_t  nw )

set combined kernel weight

参数:
nwnew combined kernel weight

在文件Kernel.h554行定义。

void set_is_initialized ( bool  p_init ) [protected]

set is initialized

参数:
p_initif optimization shall be set to initialized

在文件Kernel.h608行定义。

bool set_normalizer ( CKernelNormalizer normalizer ) [virtual]

set the current kernel normalizer

返回:
if successful

CWeightedDegreeStringKernel重载。

在文件Kernel.cpp161行定义。

virtual void set_optimization_type ( EOptimizationType  t ) [virtual]

set optimization type

参数:
toptimization type to set

CCombinedKernel重载。

在文件Kernel.h493行定义。

void set_property ( EKernelProperty  p ) [protected]

set property

参数:
pkernel property to set

在文件Kernel.h590行定义。

void set_subkernel_weights ( float64_t weights,
int32_t  num_weights 
) [virtual]

set subkernel weights

参数:
weightssubkernel weights
num_weightsnumber of weights

CCombinedKernelCWeightedDegreePositionStringKernelCWeightedDegreeStringKernel重载。

在文件Kernel.cpp460行定义。

void unset_property ( EKernelProperty  p ) [protected]

unset property

参数:
pkernel property to unset

在文件Kernel.h599行定义。


友元及相关函数文档

friend class CAvgDiagKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h151行定义。

friend class CDiceKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h159行定义。

friend class CFirstElementKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h153行定义。

friend class CMultitaskKernelMaskNormalizer [friend]

在文件Kernel.h156行定义。

friend class CMultitaskKernelMaskPairNormalizer [friend]

在文件Kernel.h157行定义。

friend class CMultitaskKernelMklNormalizer [friend]

在文件Kernel.h155行定义。

friend class CMultitaskKernelNormalizer [friend]

在文件Kernel.h154行定义。

friend class CRidgeKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h152行定义。

friend class CSqrtDiagKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h150行定义。

friend class CTanimotoKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h158行定义。

friend class CVarianceKernelNormalizer [friend]

CCommWordStringKernel重载。

在文件Kernel.h149行定义。


成员数据文档

int32_t cache_size [protected]

cache_size in MB

在文件Kernel.h744行定义。

combined kernel weight

在文件Kernel.h763行定义。

this *COULD* store the whole kernel matrix usually not applicable / necessary to compute the whole matrix

CSpectrumMismatchRBFKernelCSpectrumRBFKernel重载。

在文件Kernel.h750行定义。

CFeatures* lhs [protected]

feature vectors to occur on left hand side

在文件Kernel.h753行定义。

normalize the kernel(i,j) function based on this normalization function

在文件Kernel.h777行定义。

int32_t num_lhs [protected]

number of feature vectors on left hand side

在文件Kernel.h758行定义。

int32_t num_rhs [protected]

number of feature vectors on right hand side

在文件Kernel.h760行定义。

optimization type (currently FASTBUTMEMHUNGRY and SLOWBUTMEMEFFICIENT)

在文件Kernel.h770行定义。

bool optimization_initialized [protected]

if optimization is initialized

在文件Kernel.h766行定义。

uint64_t properties [protected]

kernel properties

在文件Kernel.h773行定义。

CFeatures* rhs [protected]

feature vectors to occur on right hand side

在文件Kernel.h755行定义。


该类的文档由以下文件生成:

SHOGUN Machine Learning Toolbox - Documentation