SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * (W) 2012 Jacob Walker 00008 * 00009 * Adapted from WeightedDegreeRBFKernel.h 00010 */ 00011 00012 #ifndef LINEARARDKERNEL_H_ 00013 #define LINEARARDKERNEL_H_ 00014 00015 #include <shogun/lib/common.h> 00016 #include <shogun/kernel/DotKernel.h> 00017 #include <shogun/features/DenseFeatures.h> 00018 00019 namespace shogun 00020 { 00021 00023 class CLinearARDKernel: public CDotKernel 00024 { 00025 public: 00027 CLinearARDKernel(); 00028 00033 CLinearARDKernel(int32_t size); 00034 00041 CLinearARDKernel(CDenseFeatures<float64_t>* l, CDenseFeatures<float64_t>* r, 00042 int32_t size=10); 00043 00044 virtual ~CLinearARDKernel(); 00045 00052 virtual bool init(CFeatures* l, CFeatures* r); 00053 00058 virtual EKernelType get_kernel_type() { return K_LINEARARD; } 00059 00064 virtual const char* get_name() const { return "LinearARDKernel"; } 00065 00070 virtual EFeatureClass get_feature_class() { return C_DENSE; } 00071 00076 virtual EFeatureType get_feature_type() { return F_DREAL; } 00077 00083 virtual void set_weight(float64_t w, index_t i); 00084 00091 virtual float64_t get_weight(index_t i); 00092 00094 virtual SGVector<float64_t> get_weights() { return m_weights; } 00095 00100 virtual void set_weights(SGVector<float64_t> weights) { m_weights=weights; } 00101 00102 protected: 00111 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00112 00117 void init_ft_weights(); 00118 00126 virtual SGMatrix<float64_t> get_parameter_gradient(const TParameter* param, 00127 index_t index=-1); 00128 00129 private: 00130 void init(); 00131 00132 protected: 00134 SGVector<float64_t> m_weights; 00135 }; 00136 } 00137 #endif /* LINEARARDKERNEL_H_ */