PLearn 0.1
|
#include <WeightedQuadraticPolynomialKernel.h>
Public Member Functions | |
WeightedQuadraticPolynomialKernel (real the_alph=1.0, real the_beta=1.0, bool call_build_=true) | |
Convenient constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual WeightedQuadraticPolynomialKernel * | deepCopy (CopiesMap &copies) const |
virtual real | evaluate (const Vec &x1, const Vec &x2) const |
** Subclasses must override this method ** | |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
real | alpha |
Weight on correlation features. | |
real | beta |
Weight on second degree features. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef Kernel | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 51 of file WeightedQuadraticPolynomialKernel.h.
typedef Kernel PLearn::WeightedQuadraticPolynomialKernel::inherited [private] |
Reimplemented from PLearn::Kernel.
Definition at line 53 of file WeightedQuadraticPolynomialKernel.h.
string PLearn::WeightedQuadraticPolynomialKernel::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
OptionList & PLearn::WeightedQuadraticPolynomialKernel::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
RemoteMethodMap & PLearn::WeightedQuadraticPolynomialKernel::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
Reimplemented from PLearn::Kernel.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
Object * PLearn::WeightedQuadraticPolynomialKernel::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
StaticInitializer WeightedQuadraticPolynomialKernel::_static_initializer_ & PLearn::WeightedQuadraticPolynomialKernel::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
void PLearn::WeightedQuadraticPolynomialKernel::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::Kernel.
Definition at line 98 of file WeightedQuadraticPolynomialKernel.cc.
References PLearn::Kernel::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::WeightedQuadraticPolynomialKernel::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Kernel.
Definition at line 107 of file WeightedQuadraticPolynomialKernel.cc.
Referenced by build(), and WeightedQuadraticPolynomialKernel().
{}
string PLearn::WeightedQuadraticPolynomialKernel::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
void PLearn::WeightedQuadraticPolynomialKernel::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::Kernel.
Definition at line 80 of file WeightedQuadraticPolynomialKernel.cc.
References alpha, beta, PLearn::OptionBase::buildoption, PLearn::declareOption(), and PLearn::Kernel::declareOptions().
{ declareOption(ol, "alpha", &WeightedQuadraticPolynomialKernel::alpha, OptionBase::buildoption, "Weight on correlation features."); declareOption(ol, "beta", &WeightedQuadraticPolynomialKernel::beta, OptionBase::buildoption, "Weight on second degree features."); // Declare options inherited from parent class. inherited::declareOptions(ol); }
static const PPath& PLearn::WeightedQuadraticPolynomialKernel::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Kernel.
Definition at line 67 of file WeightedQuadraticPolynomialKernel.h.
:
WeightedQuadraticPolynomialKernel * PLearn::WeightedQuadraticPolynomialKernel::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::Kernel.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
real PLearn::WeightedQuadraticPolynomialKernel::evaluate | ( | const Vec & | x1, |
const Vec & | x2 | ||
) | const [virtual] |
** Subclasses must override this method **
returns K(x1,x2)
Implements PLearn::Kernel.
Definition at line 113 of file WeightedQuadraticPolynomialKernel.cc.
References alpha, beta, PLearn::TVec< T >::data(), i, PLearn::ipow(), PLearn::TVec< T >::length(), PLERROR, and PLearn::TVec< T >::size().
{ #ifdef BOUNDCHECK if(x1.length()!=x2.length()) PLERROR("In WeightedQuadraticPolynomialKernel::evaluate(): " "x1 and x2 have different lengths."); #endif real res = 0; real corr = 0; if (x1.size() > 0 && x2.size() > 0) { real* v1 = x1.data(); real* v2 = x2.data(); real v1i = 0; real v2i = 0; for(int i=0; i<x1.length(); i++) { v1i = v1[i]; v2i = v2[i]; res += v1i*v2i; corr += v1i*v2i*v1i*v2i; } } //Computes K(x,y) = 0.5 * ( alpha (1 + <x,y>)^2 - alpha \n" // + 2*(1 - alpha) * \sum_i x_i y_i\n" // + (2*beta - alpha) * \sum_i x_i^2 y_i^2 )\n" return 0.5 * (alpha * ipow(res + real(1.0), 2) - alpha + 2*(1 - alpha)*res + (2*beta - alpha)*corr); }
OptionList & PLearn::WeightedQuadraticPolynomialKernel::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
OptionMap & PLearn::WeightedQuadraticPolynomialKernel::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
RemoteMethodMap & PLearn::WeightedQuadraticPolynomialKernel::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.
void PLearn::WeightedQuadraticPolynomialKernel::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Kernel.
Definition at line 146 of file WeightedQuadraticPolynomialKernel.cc.
References PLearn::Kernel::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(copies); }
Reimplemented from PLearn::Kernel.
Definition at line 67 of file WeightedQuadraticPolynomialKernel.h.
Weight on correlation features.
Definition at line 58 of file WeightedQuadraticPolynomialKernel.h.
Referenced by declareOptions(), and evaluate().
Weight on second degree features.
Definition at line 60 of file WeightedQuadraticPolynomialKernel.h.
Referenced by declareOptions(), and evaluate().