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 * Written (W) 1999-2010 Soeren Sonnenburg 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 * Copyright (C) 2010 Berlin Institute of Technology 00010 */ 00011 00012 #ifndef _SIGMOIDKERNEL_H___ 00013 #define _SIGMOIDKERNEL_H___ 00014 00015 #include "lib/common.h" 00016 #include "kernel/DotKernel.h" 00017 #include "features/DotFeatures.h" 00018 00019 namespace shogun 00020 { 00029 class CSigmoidKernel: public CDotKernel 00030 { 00031 public: 00033 CSigmoidKernel(); 00034 00041 CSigmoidKernel(int32_t size, float64_t gamma, float64_t coef0); 00042 00051 CSigmoidKernel(CDotFeatures* l, CDotFeatures* r, int32_t size, 00052 float64_t gamma, float64_t coef0); 00053 00054 virtual ~CSigmoidKernel(); 00055 00062 virtual bool init(CFeatures* l, CFeatures* r); 00063 00065 virtual void cleanup(); 00066 00071 virtual EKernelType get_kernel_type() { return K_SIGMOID; } 00072 00077 virtual const char* get_name() const { return "Sigmoid"; } 00078 00079 protected: 00088 inline virtual float64_t compute(int32_t idx_a, int32_t idx_b) 00089 { 00090 return tanh(gamma*CDotKernel::compute(idx_a,idx_b)+coef0); 00091 } 00092 00093 private: 00094 void init(); 00095 00096 protected: 00098 float64_t gamma; 00100 float64_t coef0; 00101 }; 00102 } 00103 #endif /* _SIGMOIDKERNEL_H__ */