SHOGUN  v3.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GaussianKernel.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  * Written (W) 1999-2010 Soeren Sonnenburg
8  * Written (W) 2011 Abhinav Maurya
9  * Written (W) 2012 Heiko Strathmann
10  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11  * Copyright (C) 2010 Berlin Institute of Technology
12  */
13 
14 #ifndef _GAUSSIANKERNEL_H___
15 #define _GAUSSIANKERNEL_H___
16 
17 #include <shogun/lib/common.h>
18 #include <shogun/kernel/Kernel.h>
21 
22 namespace shogun
23 {
24  class CDotFeatures;
47 {
48  public:
51 
57  CGaussianKernel(int32_t size, float64_t width);
58 
67  float64_t width, int32_t size=10);
68 
69  virtual ~CGaussianKernel();
70 
76 
78  virtual CSGObject* shallow_copy() const;
79 
86  virtual bool init(CFeatures* l, CFeatures* r);
87 
89  virtual void cleanup();
90 
95  virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
96 
101  virtual const char* get_name() const { return "GaussianKernel"; }
102 
107  virtual void set_width(float64_t w) { width=w; }
108 
113  virtual float64_t get_width() const { return width; }
114 
119  inline void set_compact_enabled(bool compact) { m_compact=compact; }
120 
125  inline bool get_compact_enabled() { return m_compact; }
126 
135  const TParameter* param, index_t index=-1);
136 
137  protected:
146  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
147 
154  virtual void load_serializable_post() throw (ShogunException);
155 
156  private:
160  void precompute_squared();
161 
168  void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
169 
170  void init();
171 
172  protected:
174  float64_t width;
180  bool m_compact;
181 };
182 }
183 #endif /* _GAUSSIANKERNEL_H__ */
void set_compact_enabled(bool compact)
EKernelType
Definition: Kernel.h:51
int32_t index_t
Definition: common.h:60
virtual void load_serializable_post()
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
parameter struct
Definition: Parameter.h:26
float64_t kernel(int32_t idx_a, int32_t idx_b)
Definition: Kernel.h:198
virtual float64_t get_width() const
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
Features that support dot products among other operations.
Definition: DotFeatures.h:41
Template class DotKernel is the base class for kernels working on DotFeatures.
Definition: DotKernel.h:29
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:114
virtual EKernelType get_kernel_type()
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
double float64_t
Definition: common.h:48
virtual CSGObject * shallow_copy() const
The well known Gaussian kernel (swiss army knife for SVMs) computed on CDotFeatures.
static CGaussianKernel * obtain_from_generic(CKernel *kernel)
The class Features is the base class of all feature objects.
Definition: Features.h:62
virtual const char * get_name() const
The Kernel base class.
Definition: Kernel.h:150
virtual bool init(CFeatures *l, CFeatures *r)
virtual void set_width(float64_t w)

SHOGUN Machine Learning Toolbox - Documentation