The Custom 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: Full symmetric kernel matrices can be stored as is or can be internally converted into (or directly given in) upper triangle representation. Also note that values are stored as 32bit floats.
The custom kernel supports subsets each on the rows and the columns.
在文件 CustomKernel.h 第 33 行定义.
静态 Public 成员函数 | |
static CKernel * | obtain_from_generic (CSGObject *kernel) |
Public 属性 | |
SGIO * | io |
Parallel * | parallel |
Version * | version |
Parameter * | m_parameters |
Parameter * | m_model_selection_parameters |
Parameter * | m_gradient_parameters |
ParameterMap * | m_parameter_map |
uint32_t | m_hash |
Protected 成员函数 | |
virtual float64_t | compute (int32_t row, int32_t col) |
void | set_property (EKernelProperty p) |
void | unset_property (EKernelProperty p) |
void | set_is_initialized (bool p_init) |
int32_t | compute_row_start (int64_t offs, int32_t n, bool symmetric) |
virtual void | load_serializable_post () throw (ShogunException) |
virtual void | save_serializable_pre () throw (ShogunException) |
virtual void | save_serializable_post () throw (ShogunException) |
virtual void | register_params () |
virtual TParameter * | migrate (DynArray< TParameter * > *param_base, const SGParamInfo *target) |
virtual void | one_to_one_migration_prepare (DynArray< TParameter * > *param_base, const SGParamInfo *target, TParameter *&replacement, TParameter *&to_migrate, char *old_name=NULL) |
virtual void | load_serializable_pre () throw (ShogunException) |
静态 Protected 成员函数 | |
template<class T > | |
static void * | get_kernel_matrix_helper (void *p) |
Protected 属性 | |
SGMatrix< float32_t > | kmatrix |
bool | upper_diagonal |
CSubsetStack * | m_row_subset_stack |
CSubsetStack * | m_col_subset_stack |
bool | m_free_km |
int32_t | cache_size |
cache_size in MB 更多... | |
KERNELCACHE_ELEM * | kernel_matrix |
CFeatures * | lhs |
feature vectors to occur on left hand side 更多... | |
CFeatures * | rhs |
feature vectors to occur on right hand side 更多... | |
bool | lhs_equals_rhs |
lhs 更多... | |
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 |
CKernelNormalizer * | normalizer |
CCustomKernel | ( | ) |
default constructor
在文件 CustomKernel.cpp 第 59 行定义.
CCustomKernel | ( | CKernel * | k | ) |
constructor
compute custom kernel from given kernel matrix
k | kernel matrix |
在文件 CustomKernel.cpp 第 66 行定义.
CCustomKernel | ( | SGMatrix< float64_t > | km | ) |
constructor
sets full kernel matrix from full kernel matrix (from double precision floats)
km | kernel matrix |
在文件 CustomKernel.cpp 第 83 行定义.
CCustomKernel | ( | SGMatrix< float32_t > | km | ) |
constructor
sets full kernel matrix from full kernel matrix (from double precision floats)
km | kernel matrix |
在文件 CustomKernel.cpp 第 92 行定义.
|
virtual |
在文件 CustomKernel.cpp 第 101 行定义.
adds a col subset of indices on top of the current subsets (possibly subset o subset. Calls subset_changed_post() afterwards
subset | subset of indices to add |
在文件 CustomKernel.cpp 第 180 行定义.
adds a row subset of indices on top of the current subsets (possibly subset o subset. Calls subset_changed_post() afterwards
subset | subset of indices to add |
在文件 CustomKernel.cpp 第 154 行定义.
|
virtualinherited |
add vector*factor to 'virtual' normal vector
vector_idx | index |
weight | weight |
被 CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearKernel, CLinearStringKernel , 以及 CWeightedCommWordStringKernel 重载.
在文件 Kernel.cpp 第 351 行定义.
|
inherited |
Builds a dictionary of all parameters in SGObject as well of those of SGObjects that are parameters of this object. Dictionary maps parameters to the objects that own them.
dict | dictionary of parameters to be built. |
在文件 SGObject.cpp 第 1174 行定义.
|
virtual |
void cleanup_custom | ( | ) |
only cleanup stuff specific to Custom kernel
在文件 CustomKernel.cpp 第 134 行定义.
|
virtualinherited |
for optimizable kernels, i.e. kernels where the weight vector can be computed explicitly (if it fits into memory)
被 CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearKernel , 以及 CLinearStringKernel 重载.
在文件 Kernel.cpp 第 356 行定义.
|
virtualinherited |
Creates a clone of the current object. This is done via recursively traversing all parameters, which corresponds to a deep copy. Calling equals on the cloned object always returns true although none of the memory of both objects overlaps.
在文件 SGObject.cpp 第 1291 行定义.
|
virtual |
method may be overwritten to update things that depend on subset
在文件 CustomKernel.cpp 第 198 行定义.
|
protectedvirtual |
compute kernel function
works with subset
row | row |
col | col |
实现了 CKernel.
在文件 CustomKernel.h 第 403 行定义.
|
virtualinherited |
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
被 CCombinedKernel, CWeightedDegreeStringKernel , 以及 CWeightedDegreePositionStringKernel 重载.
在文件 Kernel.cpp 第 344 行定义.
|
virtualinherited |
compute by subkernel
vector_idx | index |
subkernel_contrib | subkernel contribution |
被 CCombinedKernel, CWeightedDegreeStringKernel , 以及 CWeightedDegreePositionStringKernel 重载.
在文件 Kernel.cpp 第 366 行定义.
|
virtualinherited |
compute optimized
vector_idx | index to compute |
被 CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommWordStringKernel, CCommUlongStringKernel, CLinearKernel, CLinearStringKernel , 以及 CWeightedCommWordStringKernel 重载.
在文件 Kernel.cpp 第 338 行定义.
|
protectedinherited |
|
virtualinherited |
A deep copy. All the instance variables will also be copied.
在文件 SGObject.h 第 126 行定义.
|
virtualinherited |
delete optimization
被 CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommWordStringKernel, CCommUlongStringKernel, CLinearKernel , 以及 CLinearStringKernel 重载.
在文件 Kernel.cpp 第 332 行定义.
|
virtual |
initialize kernel with dummy features
Kernels always need feature objects assigned. As the custom kernel does not really require this it creates some magic dummy features that only know about the number of vectors
removes subset before
rows | features of left-hand side |
cols | features of right-hand side |
在文件 CustomKernel.cpp 第 110 行定义.
Recursively compares the current SGObject to another one. Compares all registered numerical parameters, recursion upon complex (SGObject) parameters. Does not compare pointers!
May be overwritten but please do with care! Should not be necessary in most cases.
other | object to compare with |
accuracy | accuracy to use for comparison (optional) |
tolerant | allows linient check on float equality (within accuracy) |
在文件 SGObject.cpp 第 1195 行定义.
|
inherited |
|
inherited |
|
virtual |
return feature class the kernel can deal with
实现了 CKernel.
在文件 CustomKernel.h 第 117 行定义.
|
virtual |
return feature type the kernel can deal with
实现了 CKernel.
在文件 CustomKernel.h 第 111 行定义.
returns kernel matrix as is (not possible with subset)
在文件 CustomKernel.h 第 376 行定义.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
staticprotectedinherited |
helper for computing the kernel matrix in a parallel way
p | thread parameters |
在文件 Kernel.cpp 第 522 行定义.
|
virtual |
|
inherited |
|
inherited |
|
inherited |
在文件 SGObject.cpp 第 1066 行定义.
|
inherited |
Returns description of a given parameter string, if it exists. SG_ERROR otherwise
param_name | name of the parameter |
在文件 SGObject.cpp 第 1090 行定义.
|
inherited |
Returns index of model selection parameter with provided index
param_name | name of model selection parameter |
在文件 SGObject.cpp 第 1103 行定义.
|
virtual |
|
virtualinherited |
|
virtualinherited |
get number of subkernels
被 CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCombinedKernel , 以及 CProductKernel 重载.
在文件 Kernel.cpp 第 361 行定义.
|
virtual |
get number of vectors of lhs features
works with subset
重载 CKernel .
在文件 CustomKernel.h 第 343 行定义.
|
virtual |
get number of vectors of rhs features
works with subset
重载 CKernel .
在文件 CustomKernel.h 第 355 行定义.
|
inherited |
|
virtualinherited |
return derivative with respect to specified parameter
param | the parameter |
index | the index of the element if parameter is a vector |
被 CCombinedKernel, CProductKernel, CGaussianKernel, CLinearARDKernel , 以及 CGaussianARDKernel 重载.
|
inherited |
|
virtualinherited |
get subkernel weights
num_weights | number of weights will be stored here |
被 CCombinedKernel, CWeightedDegreeStringKernel , 以及 CWeightedDegreePositionStringKernel 重载.
在文件 Kernel.cpp 第 372 行定义.
get subkernel weights (swig compatible)
被 CCombinedKernel 重载.
在文件 Kernel.cpp 第 378 行定义.
|
virtual |
test whether features have been assigned to lhs and rhs
works with subset
重载 CKernel .
在文件 CustomKernel.h 第 367 行定义.
|
inherited |
initialize kernel
removes subset before
l | features of left-hand side |
r | features of right-hand side |
重载 CKernel .
在文件 CustomKernel.cpp 第 115 行定义.
|
virtualinherited |
|
virtualinherited |
initialize optimization
count | count |
IDX | index |
weights | weights |
被 CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommWordStringKernel, CCommUlongStringKernel, CLinearKernel , 以及 CLinearStringKernel 重载.
在文件 Kernel.cpp 第 325 行定义.
|
inherited |
|
virtualinherited |
If the SGSerializable is a class template then TRUE will be returned and GENERIC is set to the type of the generic.
generic | set to the type of the generic if returning TRUE |
在文件 SGObject.cpp 第 234 行定义.
|
inherited |
|
inherited |
list kernel
在文件 Kernel.cpp 第 210 行定义.
|
inherited |
|
inherited |
maps all parameters of this instance to the provided file version and loads all parameter data from the file into an array, which is sorted (basically calls load_file_parameter(...) for all parameters and puts all results into a sorted array)
file_version | parameter version of the file |
current_version | version from which mapping begins (you want to use Version::get_version_parameter() for this in most cases) |
file | file to load from |
prefix | prefix for members |
在文件 SGObject.cpp 第 639 行定义.
|
inherited |
loads some specified parameters from a file with a specified version The provided parameter info has a version which is recursively mapped until the file parameter version is reached. Note that there may be possibly multiple parameters in the mapping, therefore, a set of TParameter instances is returned
param_info | information of parameter |
file_version | parameter version of the file, must be <= provided parameter version |
file | file to load from |
prefix | prefix for members |
在文件 SGObject.cpp 第 480 行定义.
|
virtualinherited |
Load this object from file. If it will fail (returning FALSE) then this object will contain inconsistent data and should not be used!
file | where to load from |
prefix | prefix for members |
param_version | (optional) a parameter version different to (this is mainly for testing, better do not use) |
在文件 SGObject.cpp 第 311 行定义.
|
protectedvirtualinherited |
Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_POST is called.
ShogunException | Will be thrown if an error occurres. |
重载 CSGObject .
被 CWeightedDegreePositionStringKernel, CGaussianKernel, CInverseMultiQuadricKernel, CCircularKernel , 以及 CExponentialKernel 重载.
在文件 Kernel.cpp 第 426 行定义.
|
protectedvirtualinherited |
Can (optionally) be overridden to pre-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_PRE is called.
ShogunException | Will be thrown if an error occurres. |
被 CDynamicArray< T >, CDynamicArray< float64_t >, CDynamicArray< float32_t >, CDynamicArray< int32_t >, CDynamicArray< char >, CDynamicArray< bool > , 以及 CDynamicObjectArray 重载.
在文件 SGObject.cpp 第 990 行定义.
|
inherited |
Takes a set of TParameter instances (base) with a certain version and a set of target parameter infos and recursively maps the base level wise to the current version using CSGObject::migrate(...). The base is replaced. After this call, the base version containing parameters should be of same version/type as the initial target parameter infos. Note for this to work, the migrate methods and all the internal parameter mappings have to match
param_base | set of TParameter instances that are mapped to the provided target parameter infos |
base_version | version of the parameter base |
target_param_infos | set of SGParamInfo instances that specify the target parameter base |
在文件 SGObject.cpp 第 677 行定义.
|
protectedvirtualinherited |
creates a new TParameter instance, which contains migrated data from the version that is provided. The provided parameter data base is used for migration, this base is a collection of all parameter data of the previous version. Migration is done FROM the data in param_base TO the provided param info Migration is always one version step. Method has to be implemented in subclasses, if no match is found, base method has to be called.
If there is an element in the param_base which equals the target, a copy of the element is returned. This represents the case when nothing has changed and therefore, the migrate method is not overloaded in a subclass
param_base | set of TParameter instances to use for migration |
target | parameter info for the resulting TParameter |
在文件 SGObject.cpp 第 884 行定义.
Obtains a kernel from a generic SGObject with error checking. Note that if passing NULL, result will be NULL
kernel | Object to cast to CKernel, is not SG_REFed |
在文件 Kernel.cpp 第 394 行定义.
|
protectedvirtualinherited |
This method prepares everything for a one-to-one parameter migration. One to one here means that only ONE element of the parameter base is needed for the migration (the one with the same name as the target). Data is allocated for the target (in the type as provided in the target SGParamInfo), and a corresponding new TParameter instance is written to replacement. The to_migrate pointer points to the single needed TParameter instance needed for migration. If a name change happened, the old name may be specified by old_name. In addition, the m_delete_data flag of to_migrate is set to true. So if you want to migrate data, the only thing to do after this call is converting the data in the m_parameter fields. If unsure how to use - have a look into an example for this. (base_migration_type_conversion.cpp for example)
param_base | set of TParameter instances to use for migration |
target | parameter info for the resulting TParameter |
replacement | (used as output) here the TParameter instance which is returned by migration is created into |
to_migrate | the only source that is used for migration |
old_name | with this parameter, a name change may be specified |
在文件 SGObject.cpp 第 824 行定义.
|
virtualinherited |
在文件 SGObject.cpp 第 200 行定义.
|
inherited |
prints all parameter registered for model selection and their type
在文件 SGObject.cpp 第 1042 行定义.
|
virtualinherited |
|
protectedvirtualinherited |
Separate the function of parameter registration This can be the first stage of a general framework for cross-validation or other parameter-based operations
被 CSpectrumMismatchRBFKernel, CSNPStringKernel, CANOVAKernel, CSubsequenceStringKernel, CGaussianMatchStringKernel, CGaussianShortRealKernel, CTensorProductPairKernel, CDistanceKernel , 以及 CHistogramIntersectionKernel 重载.
在文件 Kernel.cpp 第 449 行定义.
|
virtual |
removes all col subsets Calls subset_changed_post() afterwards
在文件 CustomKernel.cpp 第 192 行定义.
|
virtual |
removes all row subsets Calls subset_changed_post() afterwards
在文件 CustomKernel.cpp 第 166 行定义.
|
virtual |
removes that last added col subset from subset stack, if existing Calls subset_changed_post() afterwards
在文件 CustomKernel.cpp 第 186 行定义.
|
virtualinherited |
remove lhs from kernel
被 CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCombinedKernel, CCommUlongStringKernel , 以及 CProductKernel 重载.
在文件 Kernel.cpp 第 185 行定义.
|
virtualinherited |
|
virtualinherited |
takes all necessary steps if the rhs is removed from kernel
remove rhs from kernel
被 CCombinedKernel, CCommUlongStringKernel , 以及 CProductKernel 重载.
在文件 Kernel.cpp 第 197 行定义.
|
virtual |
removes that last added row subset from subset stack, if existing Calls subset_changed_post() afterwards
在文件 CustomKernel.cpp 第 160 行定义.
|
virtual |
method may be overwritten to update things that depend on subset
在文件 CustomKernel.cpp 第 172 行定义.
|
inherited |
|
virtualinherited |
Save this object to file.
file | where to save the object; will be closed during returning if PREFIX is an empty string. |
prefix | prefix for members |
param_version | (optional) a parameter version different to (this is mainly for testing, better do not use) |
在文件 SGObject.cpp 第 252 行定义.
|
protectedvirtualinherited |
Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::SAVE_SERIALIZABLE_POST is called.
ShogunException | Will be thrown if an error occurres. |
重载 CSGObject .
在文件 Kernel.cpp 第 441 行定义.
|
protectedvirtualinherited |
Can (optionally) be overridden to pre-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::SAVE_SERIALIZABLE_PRE is called.
ShogunException | Will be thrown if an error occurres. |
重载 CSGObject .
在文件 Kernel.cpp 第 433 行定义.
|
inherited |
|
inherited |
set full kernel matrix from full kernel matrix
for float32
works NOT with subset
在文件 CustomKernel.h 第 254 行定义.
set full kernel matrix from full kernel matrix
for float64
works NOT with subset
在文件 CustomKernel.h 第 277 行定义.
|
inherited |
在文件 SGObject.cpp 第 41 行定义.
|
inherited |
在文件 SGObject.cpp 第 46 行定义.
|
inherited |
在文件 SGObject.cpp 第 51 行定义.
|
inherited |
在文件 SGObject.cpp 第 56 行定义.
|
inherited |
在文件 SGObject.cpp 第 61 行定义.
|
inherited |
在文件 SGObject.cpp 第 66 行定义.
|
inherited |
在文件 SGObject.cpp 第 71 行定义.
|
inherited |
在文件 SGObject.cpp 第 76 行定义.
|
inherited |
在文件 SGObject.cpp 第 81 行定义.
|
inherited |
在文件 SGObject.cpp 第 86 行定义.
|
inherited |
在文件 SGObject.cpp 第 91 行定义.
|
inherited |
在文件 SGObject.cpp 第 96 行定义.
|
inherited |
在文件 SGObject.cpp 第 101 行定义.
|
inherited |
在文件 SGObject.cpp 第 106 行定义.
|
inherited |
在文件 SGObject.cpp 第 111 行定义.
|
inherited |
set generic type to T
|
inherited |
|
inherited |
|
inherited |
|
protectedinherited |
|
virtualinherited |
set the current kernel normalizer
被 CWeightedDegreeStringKernel 重载.
在文件 Kernel.cpp 第 124 行定义.
|
virtualinherited |
|
protectedinherited |
set subkernel weights
weights | new subkernel weights |
被 CCombinedKernel, CWeightedDegreeStringKernel , 以及 CWeightedDegreePositionStringKernel 重载.
在文件 Kernel.cpp 第 385 行定义.
set kernel matrix (only elements from upper triangle) from squared matrix
for float64's
works NOT with subset
在文件 CustomKernel.h 第 200 行定义.
bool set_triangle_kernel_matrix_from_full_generic | ( | SGMatrix< T > | full_kernel_matrix | ) |
set kernel matrix (only elements from upper triangle) from squared matrix
works NOT with subset
在文件 CustomKernel.h 第 214 行定义.
set kernel matrix (only elements from upper triangle) from elements of upper triangle (concat'd), including the main diagonal
small variant for floats64's, triangle needs to have less than 2**32 elements
works NOT with subset
tri_kernel_matrix | tri kernel matrix |
在文件 CustomKernel.h 第 136 行定义.
bool set_triangle_kernel_matrix_from_triangle_generic | ( | SGVector< T > | tri_kernel_matrix | ) |
set kernel matrix (only elements from upper triangle) from elements of upper triangle (concat'd), including the main diagonal
big variant, allowing the triangle to have more than 2**31-1 elements
works NOT with subset
tri_kernel_matrix | tri kernel matrix |
在文件 CustomKernel.h 第 159 行定义.
|
virtualinherited |
A shallow copy. All the SGObject instance variables will be simply assigned and SG_REF-ed.
被 CGaussianKernel 重载.
在文件 SGObject.h 第 117 行定义.
|
inherited |
unset generic type
this has to be called in classes specializing a template class
在文件 SGObject.cpp 第 241 行定义.
|
protectedinherited |
|
virtualinherited |
Updates the hash of current parameter combination
在文件 SGObject.cpp 第 187 行定义.
|
inherited |
io
在文件 SGObject.h 第 473 行定义.
|
protectedinherited |
kernel matrix
在文件 CustomKernel.h 第 431 行定义.
|
protectedinherited |
|
protected |
column subset stack
在文件 CustomKernel.h 第 439 行定义.
|
protected |
indicates whether kernel matrix is to be freed in destructor
在文件 CustomKernel.h 第 442 行定义.
|
inherited |
parameters wrt which we can compute gradients
在文件 SGObject.h 第 488 行定义.
|
inherited |
Hash of parameter values
在文件 SGObject.h 第 494 行定义.
|
inherited |
model selection parameters
在文件 SGObject.h 第 485 行定义.
|
inherited |
map for different parameter versions
在文件 SGObject.h 第 491 行定义.
|
inherited |
parameters
在文件 SGObject.h 第 482 行定义.
|
protected |
row subset stack
在文件 CustomKernel.h 第 437 行定义.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
inherited |
parallel
在文件 SGObject.h 第 476 行定义.
|
protectedinherited |
|
protected |
upper diagonal
在文件 CustomKernel.h 第 434 行定义.
|
inherited |
version
在文件 SGObject.h 第 479 行定义.