SHOGUN  6.1.3
ExponentialARDKernel.h
Go to the documentation of this file.
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 public:
158  CExponentialARDKernel(int32_t size);
159 
167  int32_t size=10);
168 
169 
176  virtual bool init(CFeatures* l, CFeatures* r);
177 
178 
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 
230 
243 
251  virtual void check_weight_gradient_index(index_t index);
252 };
253 }
254 #endif /* EXPONENTIALARDKERNEL_H */
SGVector< float64_t > m_log_weights
int32_t index_t
Definition: common.h:72
virtual const char * get_name() const
virtual SGMatrix< float64_t > compute_right_product(SGVector< float64_t >vec, float64_t &scalar_weight)
parameter struct
virtual void set_weights(SGMatrix< float64_t > weights)
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
virtual void set_scalar_weights(float64_t weight)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
SGMatrix< float64_t > get_weighted_vector(SGVector< float64_t > vec)
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()
virtual SGMatrix< float64_t > get_weights()
double float64_t
Definition: common.h:60
virtual SGVector< float64_t > get_feature_vector(int32_t idx, CFeatures *hs)
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)=0
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()
virtual void check_weight_gradient_index(index_t index)
virtual void set_vector_weights(SGVector< float64_t > weights)
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:69
static float64_t exp(float64_t x)
Definition: Math.h:551
virtual void set_matrix_weights(SGMatrix< float64_t > weights)
Exponential Kernel with Automatic Relevance Detection computed on CDotFeatures.
virtual EFeatureType get_feature_type()

SHOGUN Machine Learning Toolbox - Documentation