SHOGUN  4.1.0
ExponentialARDKernel.h
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * (W) 2015 Wu Lin
8  * (W) 2012 Jacob Walker
9  *
10  * Adapted from WeightedDegreeRBFKernel.h
11  */
12 
13 #ifndef EXPONENTIALARDKERNEL_H
14 #define EXPONENTIALARDKERNEL_H
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
19 
20 namespace shogun
21 {
22 
24 {
26  KT_DIAG=20,
28 };
29 
69 {
70 public:
73 
74  virtual ~CExponentialARDKernel();
75 
81 
86  virtual const char* get_name() const { return "ExponentialARDKernel"; }
87 
92  virtual EFeatureClass get_feature_class() { return C_DENSE; }
93 
98  virtual EFeatureType get_feature_type() { return F_DREAL; }
99 
100 private:
101  void init();
102 
103 protected:
106 
109 
112 
115 
118 
125  virtual SGVector<float64_t> get_feature_vector(int32_t idx, CFeatures* hs);
126 
136  virtual float64_t distance(int32_t idx_a, int32_t idx_b)=0;
137 
147  virtual float64_t compute(int32_t idx_a, int32_t idx_b)
148  {
149  return CMath::exp(-distance(idx_a,idx_b));
150  }
151 
152 #ifdef HAVE_LINALG_LIB
153 public:
158  CExponentialARDKernel(int32_t size);
159 
167  int32_t size=10);
168 
169 
176  virtual bool init(CFeatures* l, CFeatures* r);
177 
178 
185  virtual SGMatrix<float64_t> get_weights();
186 
197  index_t index=-1)=0;
198 
202  virtual void set_scalar_weights(float64_t weight);
203 
207  virtual void set_vector_weights(SGVector<float64_t> weights);
208 
212  virtual void set_matrix_weights(SGMatrix<float64_t> weights);
213 
214 protected:
218  virtual void set_weights(SGMatrix<float64_t> weights);
219 
221  void lazy_update_weights();
222 
229  SGMatrix<float64_t> get_weighted_vector(SGVector<float64_t> vec);
230 
242  virtual SGMatrix<float64_t> compute_right_product(SGVector<float64_t>vec, float64_t & scalar_weight);
243 
251  virtual void check_weight_gradient_index(index_t index);
252 #endif /* HAVE_LINALG_LIB */
253 };
254 }
255 #endif /* EXPONENTIALARDKERNEL_H */
SGVector< float64_t > m_log_weights
EKernelType
Definition: Kernel.h:54
int32_t index_t
Definition: common.h:62
virtual const char * get_name() const
parameter struct
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
SGMatrix< float64_t > m_weights_raw
Template class DotKernel is the base class for kernels working on DotFeatures.
Definition: DotKernel.h:31
virtual EFeatureClass get_feature_class()
double float64_t
Definition: common.h:50
virtual SGVector< float64_t > get_feature_vector(int32_t idx, CFeatures *hs)
virtual float64_t distance(int32_t idx_a, int32_t idx_b)=0
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
virtual EKernelType get_kernel_type()
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
static float64_t exp(float64_t x)
Definition: Math.h:621
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
Definition: Kernel.h:732
Exponential Kernel with Automatic Relevance Detection computed on CDotFeatures.
virtual EFeatureType get_feature_type()

SHOGUN 机器学习工具包 - 项目文档