Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::GaussianKernel Class Reference

returns exp(-norm_2(x1-x2)^2/sigma^2) More...

#include <GaussianKernel.h>

Inheritance diagram for PLearn::GaussianKernel:

Inheritance graph
[legend]
Collaboration diagram for PLearn::GaussianKernel:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GaussianKernel ()
 Default constructor.

 GaussianKernel (real the_sigma)
 Convenient constructor.

 PLEARN_DECLARE_OBJECT (GaussianKernel)
virtual void build ()
 Should call simply inherited::build(), then this class's build_().

virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
real evaluateFromSquaredNormOfDifference (real sqnorm_of_diff) const
real evaluateFromDotAndSquaredNorm (real sqnorm_x1, real dot_x1_x2, real sqnorm_x2) const
virtual void setDataForKernelMatrix (VMat the_data)
 This method precomputes the squared norm for all the data to later speed up evaluate methods.

virtual void addDataForKernelMatrix (const Vec &newRow)
 This method appends the newRow squared norm to the squarednorms Vec field.

virtual real evaluate (const Vec &x1, const Vec &x2) const
 returns K(x1,x2)

virtual real evaluate_i_j (int i, int j) const
 returns evaluate(data(i),data(j))

virtual real evaluate_i_x (int i, const Vec &x, real squared_norm_of_x=-1) const
 returns evaluate(data(i),x)

virtual real evaluate_x_i (const Vec &x, int i, real squared_norm_of_x=-1) const
 returns evaluate(x,data(i))

virtual void setParameters (Vec paramvec)
 default version produces an error


Public Attributes

bool scale_by_sigma
 Build options below.

real sigma

Static Protected Member Functions

void declareOptions (OptionList &ol)
 redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)


Protected Attributes

real minus_one_over_sigmasquare
 -1 / sigma^2

real sigmasquare_over_two
 sigma^2 / 2

Vec squarednorms
 squarednorms of the rows of the data VMat (data is a member of Kernel)


Private Types

typedef Kernel inherited

Private Member Functions

void build_ ()

Detailed Description

returns exp(-norm_2(x1-x2)^2/sigma^2)

Definition at line 54 of file GaussianKernel.h.


Member Typedef Documentation

typedef Kernel PLearn::GaussianKernel::inherited [private]
 

Reimplemented from PLearn::Kernel.

Definition at line 59 of file GaussianKernel.h.


Constructor & Destructor Documentation

PLearn::GaussianKernel::GaussianKernel  ) 
 

Default constructor.

Definition at line 59 of file GaussianKernel.cc.

PLearn::GaussianKernel::GaussianKernel real  the_sigma  ) 
 

Convenient constructor.

Definition at line 64 of file GaussianKernel.cc.

References build_().


Member Function Documentation

void PLearn::GaussianKernel::addDataForKernelMatrix const Vec newRow  )  [virtual]
 

This method appends the newRow squared norm to the squarednorms Vec field.

Reimplemented from PLearn::Kernel.

Definition at line 111 of file GaussianKernel.cc.

References PLearn::TVec< T >::length(), PLearn::VMat::length(), PLERROR, PLearn::pownorm(), PLearn::TVec< T >::resize(), and squarednorms.

void PLearn::GaussianKernel::build  )  [virtual]
 

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 88 of file GaussianKernel.cc.

References build_().

void PLearn::GaussianKernel::build_  )  [private]
 

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that it's parent's build_ has already been called.

Reimplemented from PLearn::Kernel.

Definition at line 97 of file GaussianKernel.cc.

References minus_one_over_sigmasquare, sigma, sigmasquare_over_two, and PLearn::square().

Referenced by build(), and GaussianKernel().

void PLearn::GaussianKernel::declareOptions OptionList ol  )  [static, protected]
 

redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down)

ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); }

Reimplemented from PLearn::Kernel.

Definition at line 74 of file GaussianKernel.cc.

References PLearn::declareOption(), and PLearn::OptionList.

real PLearn::GaussianKernel::evaluate const Vec x1,
const Vec x2
const [virtual]
 

returns K(x1,x2)

Implements PLearn::Kernel.

Definition at line 155 of file GaussianKernel.cc.

References PLearn::TVec< T >::data(), evaluateFromSquaredNormOfDifference(), PLearn::TVec< T >::length(), PLERROR, and val.

real PLearn::GaussianKernel::evaluate_i_j int  i,
int  j
const [virtual]
 

returns evaluate(data(i),data(j))

Reimplemented from PLearn::Kernel.

Definition at line 177 of file GaussianKernel.cc.

References PLearn::endl(), evaluateFromDotAndSquaredNorm(), PLERROR, PLearn::pownorm(), and squarednorms.

real PLearn::GaussianKernel::evaluate_i_x int  i,
const Vec x,
real  squared_norm_of_x = -1
const [virtual]
 

returns evaluate(data(i),x)

Reimplemented from PLearn::Kernel.

Definition at line 200 of file GaussianKernel.cc.

References evaluateFromDotAndSquaredNorm(), PLearn::pownorm(), squarednorms, and x.

real PLearn::GaussianKernel::evaluate_x_i const Vec x,
int  i,
real  squared_norm_of_x = -1
const [virtual]
 

returns evaluate(x,data(i))

Reimplemented from PLearn::Kernel.

Definition at line 226 of file GaussianKernel.cc.

References evaluateFromDotAndSquaredNorm(), PLearn::pownorm(), squarednorms, and x.

real PLearn::GaussianKernel::evaluateFromDotAndSquaredNorm real  sqnorm_x1,
real  dot_x1_x2,
real  sqnorm_x2
const [inline]
 

Definition at line 90 of file GaussianKernel.h.

References evaluateFromDotAndSquaredNorm().

Referenced by evaluate_i_j(), evaluate_i_x(), evaluate_x_i(), and evaluateFromDotAndSquaredNorm().

real PLearn::GaussianKernel::evaluateFromSquaredNormOfDifference real  sqnorm_of_diff  )  const [inline]
 

Definition at line 134 of file GaussianKernel.cc.

References PLearn::exp(), minus_one_over_sigmasquare, PLERROR, scale_by_sigma, and sigmasquare_over_two.

Referenced by evaluate().

void PLearn::GaussianKernel::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Definition at line 104 of file GaussianKernel.cc.

References PLearn::deepCopyField(), and squarednorms.

PLearn::GaussianKernel::PLEARN_DECLARE_OBJECT GaussianKernel   ) 
 

void PLearn::GaussianKernel::setDataForKernelMatrix VMat  the_data  )  [virtual]
 

This method precomputes the squared norm for all the data to later speed up evaluate methods.

Reimplemented from PLearn::Kernel.

Definition at line 236 of file GaussianKernel.cc.

References PLearn::VMat::length(), PLearn::TVec< T >::resize(), and squarednorms.

void PLearn::GaussianKernel::setParameters Vec  paramvec  )  [virtual]
 

default version produces an error

Reimplemented from PLearn::Kernel.

Definition at line 247 of file GaussianKernel.cc.

References minus_one_over_sigmasquare, PLWARNING, and sigma.


Member Data Documentation

real PLearn::GaussianKernel::minus_one_over_sigmasquare [protected]
 

-1 / sigma^2

Definition at line 69 of file GaussianKernel.h.

Referenced by build_(), evaluateFromSquaredNormOfDifference(), and setParameters().

bool PLearn::GaussianKernel::scale_by_sigma
 

Build options below.

Definition at line 64 of file GaussianKernel.h.

Referenced by evaluateFromSquaredNormOfDifference().

real PLearn::GaussianKernel::sigma
 

Definition at line 65 of file GaussianKernel.h.

Referenced by build_(), and setParameters().

real PLearn::GaussianKernel::sigmasquare_over_two [protected]
 

sigma^2 / 2

Definition at line 70 of file GaussianKernel.h.

Referenced by build_(), and evaluateFromSquaredNormOfDifference().

Vec PLearn::GaussianKernel::squarednorms [protected]
 

squarednorms of the rows of the data VMat (data is a member of Kernel)

Definition at line 72 of file GaussianKernel.h.

Referenced by addDataForKernelMatrix(), evaluate_i_j(), evaluate_i_x(), evaluate_x_i(), makeDeepCopyFromShallowCopy(), and setDataForKernelMatrix().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:23:26 2004 for PLearn by doxygen 1.3.7