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 
25 {
27  KT_DIAG=20,
29 };
30 
70 {
71 public:
74 
75  virtual ~CExponentialARDKernel();
76 
82 
87  virtual const char* get_name() const { return "ExponentialARDKernel"; }
88 
93  virtual EFeatureClass get_feature_class() { return C_DENSE; }
94 
99  virtual EFeatureType get_feature_type() { return F_DREAL; }
100 
101 private:
102  void init();
103 
104 protected:
107 
110 
113 
116 
119 
126  virtual SGVector<float64_t> get_feature_vector(int32_t idx, CFeatures* hs);
127 
137  virtual float64_t distance(int32_t idx_a, int32_t idx_b)=0;
138 
148  virtual float64_t compute(int32_t idx_a, int32_t idx_b)
149  {
150  return CMath::exp(-distance(idx_a,idx_b));
151  }
152 
153 #ifdef HAVE_LINALG_LIB
154 public:
159  CExponentialARDKernel(int32_t size);
160 
168  int32_t size=10);
169 
170 
177  virtual bool init(CFeatures* l, CFeatures* r);
178 
179 
186  virtual SGMatrix<float64_t> get_weights();
187 
198  index_t index=-1)=0;
199 
203  virtual void set_scalar_weights(float64_t weight);
204 
208  virtual void set_vector_weights(SGVector<float64_t> weights);
209 
213  virtual void set_matrix_weights(SGMatrix<float64_t> weights);
214 
215 protected:
219  virtual void set_weights(SGMatrix<float64_t> weights);
220 
222  void lazy_update_weights();
223 
230  SGMatrix<float64_t> get_weighted_vector(SGVector<float64_t> vec);
231 
243  virtual SGMatrix<float64_t> compute_right_product(SGVector<float64_t>vec, float64_t & scalar_weight);
244 
252  virtual void check_weight_gradient_index(index_t index);
253 #endif /* HAVE_LINALG_LIB */
254 };
255 }
256 #endif /* EXPONENTIALARDKERNEL_H */
SGVector< float64_t > m_log_weights
EKernelType
Definition: Kernel.h:57
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:850
Exponential Kernel with Automatic Relevance Detection computed on CDotFeatures.
virtual EFeatureType get_feature_type()

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