20 using namespace shogun;
50 SG_SERROR(
"CGaussianKernel::obtain_from_generic(): provided kernel is "
51 "not of type CGaussianKernel!\n");
89 int32_t num_vec=df->get_num_vectors();
92 for (int32_t i=0; i<num_vec; i++)
93 buf[i]=df->
dot(i,df, i);
101 CDotKernel::init(l, r);
102 precompute_squared();
114 int32_t len_features, power;
116 power=(len_features%2==0) ? (len_features+1):len_features;
119 float64_t result_multiplier=1-(sqrt(result))/3;
121 if (result_multiplier<=0)
124 result_multiplier=pow(result_multiplier, power);
126 return result_multiplier*exp(-result);
132 precompute_squared();
135 void CGaussianKernel::precompute_squared()
153 if (!strcmp(param->
m_name,
"width"))
161 derivative(j,k)=exp(-element)*element/
width;
168 SG_ERROR(
"Can't compute derivative wrt %s parameter\n", param->
m_name);
173 void CGaussianKernel::init()
virtual void load_serializable_post()
void set_compact_enabled(bool compact)
int32_t num_rhs
number of feature vectors on right hand side
Vector::Scalar dot(Vector a, Vector b)
virtual void load_serializable_post()
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
virtual float64_t distance(int32_t idx_a, int32_t idx_b)
float64_t kernel(int32_t idx_a, int32_t idx_b)
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
Features that support dot products among other operations.
int32_t cache_size
cache_size in MB
Template class DotKernel is the base class for kernels working on DotFeatures.
Class SGObject is the base class of all shogun objects.
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
int32_t num_lhs
number of feature vectors on left hand side
virtual CSGObject * shallow_copy() const
The well known Gaussian kernel (swiss army knife for SVMs) computed on CDotFeatures.
virtual bool init_normalizer()
CFeatures * rhs
feature vectors to occur on right hand side
static CGaussianKernel * obtain_from_generic(CKernel *kernel)
virtual EKernelType get_kernel_type()=0
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
static float64_t exp(float64_t x)
virtual bool init(CFeatures *l, CFeatures *r)
virtual ~CGaussianKernel()
virtual void set_width(float64_t w)