|
SHOGUN
v3.2.0
|
The Distance kernel takes a distance as input.
It turns a distance into something kernel like by computing
\[ k({\bf x}, {\bf x'}) = e^{-\frac{dist({\bf x}, {\bf x'})}{width}} \]
Definition at line 33 of file DistanceKernel.h.

Public Member Functions | |
| CDistanceKernel () | |
| CDistanceKernel (int32_t cache, float64_t width, CDistance *dist) | |
| CDistanceKernel (CFeatures *l, CFeatures *r, float64_t width, CDistance *dist) | |
| virtual | ~CDistanceKernel () |
| virtual bool | init (CFeatures *l, CFeatures *r) |
| virtual void | register_params () |
| virtual EKernelType | get_kernel_type () |
| virtual EFeatureType | get_feature_type () |
| virtual EFeatureClass | get_feature_class () |
| virtual const char * | get_name () const |
| virtual void | set_width (float64_t w) |
| virtual float64_t | get_width () const |
| float64_t | kernel (int32_t idx_a, int32_t idx_b) |
| SGMatrix< float64_t > | get_kernel_matrix () |
| template<class T > | |
| SGMatrix< T > | get_kernel_matrix () |
| SGVector< float64_t > | get_kernel_diagonal (SGVector< float64_t > preallocated=SGVector< float64_t >()) |
| virtual SGVector< float64_t > | get_kernel_col (int32_t j) |
| virtual SGVector< float64_t > | get_kernel_row (int32_t i) |
| virtual bool | set_normalizer (CKernelNormalizer *normalizer) |
| virtual CKernelNormalizer * | get_normalizer () |
| virtual bool | init_normalizer () |
| virtual void | cleanup () |
| void | load (CFile *loader) |
| void | save (CFile *writer) |
| CFeatures * | get_lhs () |
| CFeatures * | get_rhs () |
| virtual int32_t | get_num_vec_lhs () |
| virtual int32_t | get_num_vec_rhs () |
| virtual bool | has_features () |
| bool | get_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 More... | |
| 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_t * | get_subkernel_weights (int32_t &num_weights) |
| virtual SGVector< float64_t > | get_subkernel_weights () |
| virtual void | set_subkernel_weights (SGVector< float64_t > weights) |
| virtual SGMatrix< float64_t > | get_parameter_gradient (const TParameter *param, index_t index=-1) |
| virtual CSGObject * | shallow_copy () const |
| virtual CSGObject * | deep_copy () const |
| virtual bool | is_generic (EPrimitiveType *generic) const |
| template<class T > | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| template<> | |
| void | set_generic () |
| void | unset_generic () |
| virtual void | print_serializable (const char *prefix="") |
| virtual bool | save_serializable (CSerializableFile *file, const char *prefix="", int32_t param_version=Version::get_version_parameter()) |
| virtual bool | load_serializable (CSerializableFile *file, const char *prefix="", int32_t param_version=Version::get_version_parameter()) |
| DynArray< TParameter * > * | load_file_parameters (const SGParamInfo *param_info, int32_t file_version, CSerializableFile *file, const char *prefix="") |
| DynArray< TParameter * > * | load_all_file_parameters (int32_t file_version, int32_t current_version, CSerializableFile *file, const char *prefix="") |
| void | map_parameters (DynArray< TParameter * > *param_base, int32_t &base_version, DynArray< const SGParamInfo * > *target_param_infos) |
| void | set_global_io (SGIO *io) |
| SGIO * | get_global_io () |
| void | set_global_parallel (Parallel *parallel) |
| Parallel * | get_global_parallel () |
| void | set_global_version (Version *version) |
| Version * | get_global_version () |
| SGStringList< char > | get_modelsel_names () |
| void | print_modsel_params () |
| char * | get_modsel_param_descr (const char *param_name) |
| index_t | get_modsel_param_index (const char *param_name) |
| void | build_gradient_parameter_dictionary (CMap< TParameter *, CSGObject * > *dict) |
| virtual bool | update_parameter_hash () |
| virtual bool | equals (CSGObject *other, float64_t accuracy=0.0) |
| virtual CSGObject * | clone () |
Static Public Member Functions | |
| static CKernel * | obtain_from_generic (CSGObject *kernel) |
Public Attributes | |
| 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 Member Functions | |
| float64_t | compute (int32_t idx_a, int32_t idx_b) |
| 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 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) |
Static Protected Member Functions | |
| template<class T > | |
| static void * | get_kernel_matrix_helper (void *p) |
Protected Attributes | |
| CDistance * | distance |
| float64_t | width |
| int32_t | cache_size |
| cache_size in MB More... | |
| KERNELCACHE_ELEM * | kernel_matrix |
| CFeatures * | lhs |
| feature vectors to occur on left hand side More... | |
| CFeatures * | rhs |
| feature vectors to occur on right hand side More... | |
| bool | lhs_equals_rhs |
| lhs More... | |
| int32_t | num_lhs |
| number of feature vectors on left hand side More... | |
| int32_t | num_rhs |
| number of feature vectors on right hand side More... | |
| float64_t | combined_kernel_weight |
| bool | optimization_initialized |
| EOptimizationType | opt_type |
| uint64_t | properties |
| CKernelNormalizer * | normalizer |
| CDistanceKernel | ( | ) |
default constructor
Definition at line 20 of file DistanceKernel.cpp.
| CDistanceKernel | ( | int32_t | cache, |
| float64_t | width, | ||
| CDistance * | dist | ||
| ) |
constructor
| cache | cache size |
| width | width |
| dist | distance |
Definition at line 26 of file DistanceKernel.cpp.
| CDistanceKernel | ( | CFeatures * | l, |
| CFeatures * | r, | ||
| float64_t | width, | ||
| CDistance * | dist | ||
| ) |
constructor
| l | features of left-hand side |
| r | features of right-hand side |
| width | width |
| dist | distance |
Definition at line 35 of file DistanceKernel.cpp.
|
virtual |
Definition at line 46 of file DistanceKernel.cpp.
|
virtualinherited |
add vector*factor to 'virtual' normal vector
| vector_idx | index |
| weight | weight |
Reimplemented in CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearKernel, CLinearStringKernel, and CWeightedCommWordStringKernel.
Definition at line 351 of file Kernel.cpp.
|
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. |
Definition at line 1156 of file SGObject.cpp.
|
virtualinherited |
clean up your kernel
base method only removes lhs and rhs overload to add further cleanup but make sure CKernel::cleanup() is called
Reimplemented in CWeightedDegreePositionStringKernel, CCustomKernel, CWeightedDegreeStringKernel, COligoStringKernel, CStringSubsequenceKernel, CGaussianKernel, CPyramidChi2, CCommWordStringKernel, CSpectrumMismatchRBFKernel, CWeightedCommWordStringKernel, CSalzbergWordStringKernel, CCommUlongStringKernel, CBesselKernel, CSNPStringKernel, CPolyKernel, CPolyMatchStringKernel, CPolyMatchWordStringKernel, CCombinedKernel, CSimpleLocalityImprovedStringKernel, CWaveletKernel, CExponentialKernel, CGaussianMatchStringKernel, CSpectrumRBFKernel, CFixedDegreeStringKernel, CSigmoidKernel, CSplineKernel, CHistogramWordStringKernel, CProductKernel, CLocalAlignmentStringKernel, CSparseSpatialSampleStringKernel, CLinearKernel, and CLinearStringKernel.
Definition at line 147 of file Kernel.cpp.
|
virtualinherited |
for optimizable kernels, i.e. kernels where the weight vector can be computed explicitly (if it fits into memory)
Reimplemented in CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommUlongStringKernel, CCommWordStringKernel, CLinearKernel, and CLinearStringKernel.
Definition at line 356 of file Kernel.cpp.
|
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.
Definition at line 1273 of file SGObject.cpp.
|
protectedvirtual |
compute kernel function for features a and b idx_{a,b} denote the index of the feature vectors in the corresponding feature object
| idx_a | index a |
| idx_b | index b |
Implements CKernel.
Definition at line 62 of file DistanceKernel.cpp.
|
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
Reimplemented in CCombinedKernel, CWeightedDegreeStringKernel, and CWeightedDegreePositionStringKernel.
Definition at line 344 of file Kernel.cpp.
|
virtualinherited |
compute by subkernel
| vector_idx | index |
| subkernel_contrib | subkernel contribution |
Reimplemented in CCombinedKernel, CWeightedDegreeStringKernel, and CWeightedDegreePositionStringKernel.
Definition at line 366 of file Kernel.cpp.
|
virtualinherited |
compute optimized
| vector_idx | index to compute |
Reimplemented in CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommWordStringKernel, CCommUlongStringKernel, CLinearKernel, CLinearStringKernel, and CWeightedCommWordStringKernel.
Definition at line 338 of file Kernel.cpp.
|
protectedinherited |
|
virtualinherited |
A deep copy. All the instance variables will also be copied.
Definition at line 126 of file SGObject.h.
|
virtualinherited |
delete optimization
Reimplemented in CCombinedKernel, CWeightedDegreeStringKernel, CWeightedDegreePositionStringKernel, CCommWordStringKernel, CCommUlongStringKernel, CLinearKernel, and CLinearStringKernel.
Definition at line 332 of file Kernel.cpp.
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) |
Definition at line 1177 of file SGObject.cpp.
|
inherited |
|
inherited |
|
virtual |
return feature class the kernel can deal with
Implements CKernel.
Reimplemented in CBesselKernel.
Definition at line 87 of file DistanceKernel.h.
|
virtual |
return feature type the kernel can deal with
Implements CKernel.
Reimplemented in CBesselKernel.
Definition at line 81 of file DistanceKernel.h.
|
inherited |
|
inherited |
|
inherited |
|
inherited |