PLearn 0.1
|
This class implements an Ln distance (defaults to L2 i.e. euclidean distance). More...
#include <CosKernel.h>
Public Member Functions | |
CosKernel () | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual CosKernel * | deepCopy (CopiesMap &copies) const |
virtual real | evaluate (const Vec &x1, const Vec &x2) const |
** Subclasses must override this method ** | |
virtual real | evaluate_i_j (int i, int j) const |
returns evaluate(data(i),data(j)) | |
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 () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Private Types | |
typedef DistanceKernel | inherited |
This class implements an Ln distance (defaults to L2 i.e. euclidean distance).
Definition at line 49 of file CosKernel.h.
typedef DistanceKernel PLearn::CosKernel::inherited [private] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 54 of file CosKernel.h.
PLearn::CosKernel::CosKernel | ( | ) |
Definition at line 54 of file CosKernel.cc.
References n.
{ n=2.0; optimized=false; pow_distance=false; ignore_missing=false; }
string PLearn::CosKernel::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
OptionList & PLearn::CosKernel::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
RemoteMethodMap & PLearn::CosKernel::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
Object * PLearn::CosKernel::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
StaticInitializer CosKernel::_static_initializer_ & PLearn::CosKernel::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
string PLearn::CosKernel::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
void PLearn::CosKernel::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::DistanceKernel.
Definition at line 65 of file CosKernel.cc.
References PLearn::DistanceKernel::ignore_missing, PLearn::DistanceKernel::n, PLearn::OptionBase::nosave, PLearn::DistanceKernel::optimized, PLearn::DistanceKernel::pow_distance, and PLearn::redeclareOption().
{ inherited::declareOptions(ol); redeclareOption(ol, "n", &CosKernel::n, OptionBase::nosave, "Obsolete option for cosinus kernel."); redeclareOption(ol, "pow_distance", &CosKernel::pow_distance, OptionBase::nosave, "Obsolete option for cosinus kernel."); redeclareOption(ol, "optimized", &CosKernel::optimized, OptionBase::nosave, "Obsolete option for cosinus kernel."); redeclareOption(ol, "ignore_missing", &CosKernel::ignore_missing, OptionBase::nosave, "Obsolete option for cosinus kernel."); }
static const PPath& PLearn::CosKernel::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 62 of file CosKernel.h.
: static void declareOptions(OptionList& ol);
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
** Subclasses must override this method **
returns K(x1,x2)
Reimplemented from PLearn::DistanceKernel.
Definition at line 85 of file CosKernel.cc.
References PLearn::dot(), PLearn::norm(), and PLERROR.
{ if (ignore_missing && !pow_distance) PLERROR("In CosKernel::evaluate(int i, int j) - 'ignore_missing' " "implemented only if pow_distance is set"); static real cosinus; cosinus = dot(x1, x2) / ( norm(x1) * norm(x2) ); return (1.-cosinus)*.5; }
returns evaluate(data(i),data(j))
Reimplemented from PLearn::DistanceKernel.
Definition at line 97 of file CosKernel.cc.
References PLearn::sqrt().
{ static real cosinus; if (i == j) // The case 'i == j' can cause precision issues because of the optimized // formula below. Thus we make sure we always return 0. return 0; cosinus = data->dot(i, j, data_inputsize) / sqrt(squarednorms[i] * squarednorms[j]); return (1.-cosinus)*.5; }
OptionList & PLearn::CosKernel::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
OptionMap & PLearn::CosKernel::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
RemoteMethodMap & PLearn::CosKernel::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::DistanceKernel.
Definition at line 49 of file CosKernel.cc.
Reimplemented from PLearn::DistanceKernel.
Definition at line 62 of file CosKernel.h.