latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiSigmoidKernel.h 00027 * authors ....: Jochen Wickel 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 05.11.2001 00030 * revisions ..: $Id: ltiSigmoidKernel.h,v 1.6 2006/02/07 18:26:20 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_SIGMOID_KERNEL 00034 #define _LTI_SIGMOID_KERNEL 00035 00036 #include "ltiKernelFunctor.h" 00037 00038 namespace lti { 00039 00040 /** 00041 * This class defines a "sigmoid" kernel functor. It is used in 00042 * Support Vector Machines (lti::svm) to simulate a multilayer 00043 * perceptron. 00044 * 00045 * Here is \f$ K(A,B) = \tanh\left(\kappa (A \cdot B) + \theta 00046 * \right)\f$. 00047 * The terms \f$\kappa\f$ (<code>kappa</code>) and \f$\theta\f$ 00048 * (<code>theta</code>) are given through the parameters object, and only 00049 * some of values satisfy the Mercer's theorem. 00050 */ 00051 class sigmoidKernel: public kernelFunctor<double> { 00052 00053 public: 00054 /** 00055 * the parameters for the class distanceFunctor 00056 */ 00057 class parameters : public kernelFunctor<double>::parameters { 00058 public: 00059 /** 00060 * default constructor 00061 */ 00062 parameters(); 00063 00064 /** 00065 * copy constructor 00066 * @param other the parameters object to be copied 00067 */ 00068 parameters(const parameters& other); 00069 00070 /** 00071 * returns name of this type 00072 */ 00073 const char* getTypeName() const; 00074 00075 /** 00076 * copy the contents of a parameters object 00077 * @param other the parameters object to be copied 00078 * @return a reference to this parameters object 00079 */ 00080 parameters& copy(const parameters& other); 00081 00082 /** 00083 * returns a pointer to a clone of the parameters 00084 */ 00085 virtual functor::parameters* clone() const; 00086 00087 /** 00088 * write the parameters in the given ioHandler 00089 * @param handler the ioHandler to be used 00090 * @param complete if true (the default) the enclosing begin/end will 00091 * be also written, otherwise only the data block will be written. 00092 * @return true if write was successful 00093 */ 00094 virtual bool write(ioHandler& handler, 00095 const bool complete=true) const; 00096 00097 /** 00098 * read the parameters from the given ioHandler 00099 * @param handler the ioHandler to be used 00100 * @param complete if true (the default) the enclosing begin/end will 00101 * be also written, otherwise only the data block will be written. 00102 * @return true if write was successful 00103 */ 00104 virtual bool read(ioHandler& handler,const bool complete=true); 00105 00106 # ifdef _LTI_MSC_6 00107 /** 00108 * this function is required by MSVC only, as a workaround for a 00109 * very awful bug, which exists since MSVC V.4.0, and still by 00110 * V.6.0 with all bugfixes (so called "service packs") remains 00111 * there... This method is public due to another bug!, so please 00112 * NEVER EVER call this method directly 00113 */ 00114 bool readMS(ioHandler& handler,const bool complete=true); 00115 00116 /** 00117 * this function is required by MSVC only, as a workaround for a 00118 * very awful bug, which exists since MSVC V.4.0, and still by 00119 * V.6.0 with all bugfixes (so called "service packs") remains 00120 * there... This method is public due to another bug!, so please 00121 * NEVER EVER call this method directly 00122 */ 00123 bool writeMS(ioHandler& handler,const bool complete=true) const; 00124 # endif 00125 00126 /** 00127 * Slope of sigmoid function. 00128 */ 00129 double kappa; 00130 00131 /** 00132 * Offset of sigmoid function. 00133 */ 00134 double theta; 00135 }; 00136 00137 /** 00138 * default constructor 00139 */ 00140 sigmoidKernel(); 00141 00142 /** 00143 * copy constructor 00144 * @param other the object to be copied 00145 */ 00146 sigmoidKernel(const sigmoidKernel& other); 00147 00148 /** 00149 * returns the name of this type ("sigmoidKernel") 00150 */ 00151 virtual const char* getTypeName() const; 00152 00153 /** 00154 * calculate the distance between the vectors a and b 00155 * @param a the first vector<T> 00156 * @param b the second vector<T> 00157 * @return the kernel function value of the vectors 00158 */ 00159 virtual double apply(const vector<double>& a, const vector<double>& b) const; 00160 00161 /** 00162 * returns a pointer to a clone of this functor. 00163 */ 00164 virtual functor* clone() const; 00165 00166 /** 00167 * returns used parameters 00168 */ 00169 const parameters& getParameters() const; 00170 }; 00171 00172 } 00173 00174 #endif