This kernel allows for custom user provided kernel matrices. For squared training matrices it allows to store only the upper triangle of the kernel to save memory. Also note that values are stored as 32bit floats.
Definition at line 26 of file CustomKernel.h.
CCustomKernel::CCustomKernel | ( | ) |
default constructor
Definition at line 16 of file CustomKernel.cpp.
constructor
l | features of left-hand side | |
r | features of right-hand side |
Definition at line 21 of file CustomKernel.cpp.
CCustomKernel::~CCustomKernel | ( | ) | [virtual] |
Definition at line 29 of file CustomKernel.cpp.
SHORTREAL * CCustomKernel::get_kernel_matrix_shortreal | ( | INT & | m, | |
INT & | n, | |||
SHORTREAL * | target = NULL | |||
) | [virtual] |
get kernel matrix shortreal
m | dimension m of matrix | |
n | dimension n of matrix | |
target | target for kernel matrix |
Reimplemented from CKernel.
Definition at line 34 of file CustomKernel.cpp.
initialize kernel
l | features of left-hand side | |
r | features of right-hand side |
Reimplemented from CKernel.
Definition at line 56 of file CustomKernel.cpp.
void CCustomKernel::cleanup | ( | ) | [virtual] |
bool CCustomKernel::load_init | ( | FILE * | src | ) | [virtual] |
load kernel init_data
src | file to load from |
Implements CKernel.
Definition at line 82 of file CustomKernel.cpp.
bool CCustomKernel::save_init | ( | FILE * | dest | ) | [virtual] |
save kernel init_data
dest | file to save to |
Implements CKernel.
Definition at line 87 of file CustomKernel.cpp.
virtual EKernelType CCustomKernel::get_kernel_type | ( | ) | [virtual] |
return what type of kernel we are
Implements CKernel.
Definition at line 79 of file CustomKernel.h.
virtual EFeatureType CCustomKernel::get_feature_type | ( | ) | [virtual] |
return feature type the kernel can deal with
Implements CKernel.
Definition at line 85 of file CustomKernel.h.
virtual EFeatureClass CCustomKernel::get_feature_class | ( | ) | [virtual] |
return feature class the kernel can deal with
Implements CKernel.
Definition at line 91 of file CustomKernel.h.
virtual const CHAR* CCustomKernel::get_name | ( | ) | [virtual] |
return the kernel's name
Implements CKernel.
Definition at line 97 of file CustomKernel.h.
set kernel matrix (only elements from upper triangle) from elements of upper triangle (concat'd), including the main diagonal
km | kernel matrix | |
len | denotes the size of the array and should match len=cols*(cols+1)/2 |
Definition at line 93 of file CustomKernel.cpp.
set kernel matrix (only elements from upper triangle) from squared matrix
km | kernel matrix | |
rows | number of rows in matrix | |
cols | number of cols in matrix |
Definition at line 126 of file CustomKernel.cpp.
set full kernel matrix from full kernel matrix
km | kernel matrix | |
rows | number of rows in matrix | |
cols | number of cols in matrix |
Definition at line 154 of file CustomKernel.cpp.
compute kernel function
row | row | |
col | col |
Implements CKernel.
Definition at line 135 of file CustomKernel.h.
get kernel matrix
dst | destination where matrix will be stored | |
m | dimension m of matrix | |
n | dimension n of matrix |
Definition at line 79 of file Kernel.cpp.
get kernel matrix real
m | dimension m of matrix | |
n | dimension n of matrix | |
target | the kernel matrix |
Definition at line 216 of file Kernel.cpp.
bool CKernel::load | ( | CHAR * | fname | ) | [inherited] |
load the kernel matrix
fname | filename to load from |
Definition at line 322 of file Kernel.cpp.
bool CKernel::save | ( | CHAR * | fname | ) | [inherited] |
save kernel matrix
fname | filename to save to |
Definition at line 327 of file Kernel.cpp.
CFeatures* CKernel::get_lhs | ( | ) | [inherited] |
CFeatures* CKernel::get_rhs | ( | ) | [inherited] |
INT CKernel::get_num_vec_lhs | ( | ) | [inherited] |
INT CKernel::get_num_vec_rhs | ( | ) | [inherited] |
bool CKernel::has_features | ( | ) | [inherited] |
void CKernel::remove_lhs_and_rhs | ( | ) | [virtual, inherited] |
remove lhs and rhs from kernel
Definition at line 358 of file Kernel.cpp.
void CKernel::remove_lhs | ( | ) | [virtual, inherited] |
remove lhs from kernel
Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 370 of file Kernel.cpp.
void CKernel::remove_rhs | ( | ) | [virtual, inherited] |
takes all necessary steps if the rhs is removed from kernel
remove rhs from kernel
Reimplemented in CCombinedKernel, CCommUlongStringKernel, and CCommWordStringKernel.
Definition at line 379 of file Kernel.cpp.
void CKernel::set_cache_size | ( | INT | size | ) | [inherited] |
int CKernel::get_cache_size | ( | ) | [inherited] |
void CKernel::list_kernel | ( | ) | [inherited] |
list kernel
Definition at line 389 of file Kernel.cpp.
bool CKernel::has_property | ( | EKernelProperty | p | ) | [inherited] |
void CKernel::clear_normal | ( | ) | [virtual, inherited] |
for optimizable kernels, i.e. kernels where the weight vector can be computed explicitely (if it fits into memory)
Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 578 of file Kernel.cpp.
add vector*factor to 'virtual' normal vector
vector_idx | index | |
weight | weight |
Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedCommWordStringKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 573 of file Kernel.cpp.
EOptimizationType CKernel::get_optimization_type | ( | ) | [inherited] |
virtual void CKernel::set_optimization_type | ( | EOptimizationType | t | ) | [virtual, inherited] |
bool CKernel::get_is_initialized | ( | ) | [inherited] |
initialize optimization
count | count | |
IDX | index | |
weights | weights |
Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 550 of file Kernel.cpp.
bool CKernel::delete_optimization | ( | ) | [virtual, inherited] |
delete optimization
Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 556 of file Kernel.cpp.
bool CKernel::init_optimization_svm | ( | CSVM * | svm | ) | [inherited] |
initialize optimization
svm | svm model |
Definition at line 644 of file Kernel.cpp.
compute optimized
vector_idx | index to compute |
Reimplemented in CCombinedKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearByteKernel, CLinearKernel, CLinearStringKernel, CLinearWordKernel, CSparseLinearKernel, CWeightedCommWordStringKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 562 of file Kernel.cpp.
void CKernel::compute_batch | ( | INT | num_vec, | |
INT * | vec_idx, | |||
DREAL * | target, | |||
INT | num_suppvec, | |||
INT * | IDX, | |||
DREAL * | alphas, | |||
DREAL | factor = 1.0 | |||
) | [virtual, inherited] |
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
Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 568 of file Kernel.cpp.
DREAL CKernel::get_combined_kernel_weight | ( | ) | [inherited] |
void CKernel::set_combined_kernel_weight | ( | double | nw | ) | [inherited] |
INT CKernel::get_num_subkernels | ( | ) | [virtual, inherited] |
get number of subkernels
Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 583 of file Kernel.cpp.
void CKernel::compute_by_subkernel | ( | INT | vector_idx, | |
DREAL * | subkernel_contrib | |||
) | [virtual, inherited] |
compute by subkernel
vector_idx | index | |
subkernel_contrib | subkernel contribution |
Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 588 of file Kernel.cpp.
get subkernel weights
num_weights | number of weights will be stored here |
Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 593 of file Kernel.cpp.
set subkernel weights
weights | subkernel weights | |
num_weights | number of weights |
Reimplemented in CCombinedKernel, CWeightedDegreePositionStringKernel, and CWeightedDegreeStringKernel.
Definition at line 599 of file Kernel.cpp.
bool CKernel::get_precompute_matrix | ( | ) | [inherited] |
bool CKernel::get_precompute_subkernel_matrix | ( | ) | [inherited] |
virtual void CKernel::set_precompute_matrix | ( | bool | flag, | |
bool | subkernel_flag | |||
) | [virtual, inherited] |
set precompute matrix
flag | flag | |
subkernel_flag | subkernel flag |
Reimplemented in CCombinedKernel.
void CKernel::set_property | ( | EKernelProperty | p | ) | [protected, inherited] |
void CKernel::unset_property | ( | EKernelProperty | p | ) | [protected, inherited] |
void CKernel::set_is_initialized | ( | bool | p_init | ) | [protected, inherited] |
void CKernel::do_precompute_matrix | ( | ) | [protected, inherited] |
SHORTREAL* CCustomKernel::kmatrix [protected] |
kernel matrix
Definition at line 158 of file CustomKernel.h.
INT CCustomKernel::num_rows [protected] |
number of rows
Definition at line 160 of file CustomKernel.h.
INT CCustomKernel::num_cols [protected] |
number of columns
Definition at line 162 of file CustomKernel.h.
bool CCustomKernel::upper_diagonal [protected] |
upper diagonal
Definition at line 164 of file CustomKernel.h.
INT CKernel::cache_size [protected, inherited] |
KERNELCACHE_ELEM* CKernel::kernel_matrix [protected, inherited] |
SHORTREAL* CKernel::precomputed_matrix [protected, inherited] |
bool CKernel::precompute_subkernel_matrix [protected, inherited] |
bool CKernel::precompute_matrix [protected, inherited] |
CFeatures* CKernel::lhs [protected, inherited] |
CFeatures* CKernel::rhs [protected, inherited] |
DREAL CKernel::combined_kernel_weight [protected, inherited] |
bool CKernel::optimization_initialized [protected, inherited] |
EOptimizationType CKernel::opt_type [protected, inherited] |
ULONG CKernel::properties [protected, inherited] |
CParallel CSGObject::parallel [static, inherited] |
Definition at line 105 of file SGObject.h.
CIO CSGObject::io [static, inherited] |
Definition at line 106 of file SGObject.h.
CVersion CSGObject::version [static, inherited] |
Definition at line 107 of file SGObject.h.