SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LinearARDKernel.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 LINEARARDKERNEL_H
14 #define LINEARARDKERNEL_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 
67 {
68 public:
71 
72  virtual ~CLinearARDKernel();
73 
78  virtual EKernelType get_kernel_type() { return K_LINEARARD; }
79 
84  virtual const char* get_name() const=0;
85 
90  virtual EFeatureClass get_feature_class() { return C_DENSE; }
91 
96  virtual EFeatureType get_feature_type() { return F_DREAL; }
97 
98 private:
99  void initialize();
100 
101 protected:
104 
107 
114  virtual SGVector<float64_t> get_feature_vector(int32_t idx, CFeatures* hs);
115 
116 #ifdef HAVE_LINALG_LIB
117 public:
122  CLinearARDKernel(int32_t size);
123 
131  int32_t size=10);
132 
133 
140  virtual bool init(CFeatures* l, CFeatures* r);
141 
142 
149  virtual SGMatrix<float64_t> get_weights();
150 
161  index_t index=-1)=0;
162 
166  virtual void set_scalar_weights(float64_t weight);
167 
171  virtual void set_vector_weights(SGVector<float64_t> weights);
172 
176  virtual void set_matrix_weights(SGMatrix<float64_t> weights);
177 
178 protected:
179 
187  virtual void set_weights(SGMatrix<float64_t> weights);
188 
197  virtual float64_t compute(int32_t idx_a, int32_t idx_b)=0;
198 
205  virtual float64_t compute_helper(SGVector<float64_t> avec,
206  SGVector<float64_t>bvec);
207 
217  virtual float64_t compute_gradient_helper(SGVector<float64_t> avec, SGVector<float64_t> bvec,
218  float64_t scale, index_t index);
219 
228  virtual SGMatrix<float64_t> compute_right_product(SGVector<float64_t>right_vec, float64_t & scalar_weight);
229 
237  virtual void check_weight_gradient_index(index_t index);
238 #endif /* HAVE_LINALG_LIB */
239 };
240 }
241 #endif /* _LINEARARDKERNEL_H_ */
virtual EKernelType get_kernel_type()
EKernelType
Definition: Kernel.h:57
int32_t index_t
Definition: common.h:62
Linear Kernel with Automatic Relevance Detection computed on CDotFeatures.
parameter struct
SGMatrix< float64_t > m_weights
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
Definition: DotKernel.h:123
virtual SGVector< float64_t > get_feature_vector(int32_t idx, CFeatures *hs)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual const char * get_name() const =0
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
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 bool init(CFeatures *l, CFeatures *r)
Definition: DotKernel.h:65
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
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
void scale(Matrix A, Matrix B, typename Matrix::Scalar alpha)
Definition: Core.h:93
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
Definition: Kernel.h:850
virtual EFeatureType get_feature_type()

SHOGUN Machine Learning Toolbox - Documentation