PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <PLMathTest.h>
Public Member Functions | |
PLMathTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual PLMathTest * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual void | perform () |
The method performing the test. | |
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 | |
map< string, Vec > | results |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef PTest | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 61 of file PLMathTest.h.
typedef PTest PLearn::PLMathTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file PLMathTest.h.
PLearn::PLMathTest::PLMathTest | ( | ) |
Default constructor.
Definition at line 60 of file PLMathTest.cc.
{ // ... // ### You may (or not) want to call build_() to finish building the object // ### (doing so assumes the parent classes' build_() have been called too // ### in the parent classes' constructors, something that you must ensure) }
string PLearn::PLMathTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
OptionList & PLearn::PLMathTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
RemoteMethodMap & PLearn::PLMathTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
Object * PLearn::PLMathTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
StaticInitializer PLMathTest::_static_initializer_ & PLearn::PLMathTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
void PLearn::PLMathTest::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::PTest.
Definition at line 73 of file PLMathTest.cc.
{ inherited::build(); build_(); }
void PLearn::PLMathTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 117 of file PLMathTest.cc.
{ // ### This method should do the real building of the object, // ### according to set 'options', in *any* situation. // ### Typical situations include: // ### - Initial building of an object from a few user-specified options // ### - Building of a "reloaded" object: i.e. from the complete set of all serialised options. // ### - Updating or "re-building" of an object after a few "tuning" options have been modified. // ### You should assume that the parent class' build_() has already been called. }
string PLearn::PLMathTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
void PLearn::PLMathTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 99 of file PLMathTest.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), and results.
{ // ### Declare all of this object's options here // ### For the "flags" of each option, you should typically specify // ### one of OptionBase::buildoption, OptionBase::learntoption or // ### OptionBase::tuningoption. Another possible flag to be combined with // ### is OptionBase::nosave declareOption(ol, "results", &PLMathTest::results, OptionBase::buildoption, "Map storing all test results."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::PLMathTest::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PTest.
Definition at line 86 of file PLMathTest.h.
:
//##### Protected Options ###############################################
PLMathTest * PLearn::PLMathTest::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
OptionList & PLearn::PLMathTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
OptionMap & PLearn::PLMathTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
RemoteMethodMap & PLearn::PLMathTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 55 of file PLMathTest.cc.
void PLearn::PLMathTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 82 of file PLMathTest.cc.
References PLERROR.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### Remove this line when you have fully implemented this method. PLERROR("PLMathTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::PLMathTest::perform | ( | ) | [virtual] |
The method performing the test.
A typical test consists in some output (to pout and / or perr), and updates of this object's options.
Reimplemented from PLearn::PTest.
Definition at line 131 of file PLMathTest.cc.
References PLearn::TVec< T >::append(), PLearn::PRandom::common(), PLearn::d_hinge_loss(), PLearn::d_soft_slope(), PLearn::dilogarithm(), DOUBLE_TO_INT, PLearn::exp(), PLearn::FABS(), PLearn::fastsigmoid(), PLearn::fasttanh(), PLearn::PStream::flush(), PLearn::hard_slope(), PLearn::hard_slope_integral(), PLearn::hinge_loss(), i, PLearn::inverse_sigmoid(), PLearn::inverse_softplus(), PLearn::ipow(), PLearn::is_equal(), PLearn::is_integer(), PLearn::is_missing(), PLearn::is_positive(), j, PLearn::TVec< T >::length(), PLearn::log(), PLearn::logadd(), PLearn::logsub(), PLearn::logtwo(), MISSING_VALUE, PLearn::mypow(), n, PLearn::n_choose(), PLearn::negative(), PLearn::openString(), pl_log, PLearn::PStream::plearn_ascii, PLearn::positive(), PLearn::safeexp(), PLearn::safeflog(), PLearn::safeflog2(), PLearn::safelog(), PLearn::sigmoid(), PLearn::sign(), PLearn::soft_slope(), PLearn::soft_slope_integral(), PLearn::softplus(), PLearn::softplus_primitive(), PLearn::sqrt(), PLearn::square(), PLearn::tabulated_soft_slope(), PLearn::tabulated_soft_slope_integral(), PLearn::tabulated_softplus(), PLearn::tabulated_softplus_primitive(), PLearn::tanh(), PLearn::ultrafastsigmoid(), PLearn::ultrafasttanh(), and x.
{ int n = 20; TVec<int> bounds; string bounds_str = "[ 1 10 50 1000 ]"; PStream read_bounds = openString(bounds_str, PStream::plearn_ascii); read_bounds >> bounds; read_bounds.flush(); Vec samples; Vec vec(n); for (int i = 0; i < bounds.length(); i++) { PRandom::common(false)->fill_random_uniform(vec,-bounds[i],bounds[i]); samples.append(vec); } samples.append(0); samples.append(1); samples.append(-1); samples.append(MISSING_VALUE); samples.append(INFINITY); samples.append(-INFINITY); PP<ProgressBar> pb = new ProgressBar("Performing tests", samples.length()); for (int i = 0; i < samples.length(); i++) { int j; real x = samples[i]; results["data"].append(x); DOUBLE_TO_INT(x, j); results["DOUBLE_TO_INT"].append(j); results["sign"].append(sign(x)); results["positive"].append(positive(x)); results["negative"].append(negative(x)); results["is_equal_1.00000001"].append(is_equal(x, x * 1.00000001)); results["is_equal_1.001"].append(is_equal(x, x * 1.001)); results["square"].append(square(x)); results["hinge_loss_1"].append(hinge_loss(x, 1)); results["d_hinge_loss_1"].append(d_hinge_loss(x, 1)); results["is_missing"].append(is_missing(x)); results["is_integer"].append(is_integer(x)); results["FABS"].append(FABS(x)); results["mypow"].append(mypow(x,x)); if (int(x) >= 0) { results["ipow_real"].append(ipow(x,int(x))); results["ipow_int"].append(ipow(int(x),int(x))); } else { results["ipow_real"].append(0); results["ipow_int"].append(0); } results["sigmoid"].append(sigmoid(x)); results["is_positive"].append(is_positive(x)); if (x >= 0 && x <= 1) results["inverse_sigmoid"].append(inverse_sigmoid(x)); else results["inverse_sigmoid"].append(0); results["softplus"].append(softplus(x)); results["inverse_softplus"].append(inverse_softplus(x)); results["hard_slope"].append(hard_slope(x)); results["soft_slope"].append(soft_slope(x)); results["d_soft_slope"].append(d_soft_slope(x)); results["n_choose"].append(n_choose(int(x), int(x) + 2)); if (x >= 0) { results["safelog"].append(safelog(x)); results["safeflog"].append(safeflog(x)); results["safeflog"].append(safeflog(x, x + 3)); results["safeflog2"].append(safeflog2(x)); } else { results["safelog"].append(0); results["safeflog"].append(0); results["safeflog"].append(0); results["safeflog2"].append(0); } results["sqrt"].append(sqrt(x)); results["tanh"].append(tanh(x)); results["exp"].append(exp(x)); results["safeexp"].append(safeexp(x)); results["pl_log"].append(pl_log(x)); results["log_a_b"].append(log(x, x + 3)); results["logtwo"].append(logtwo(x)); results["logadd"].append(logadd(x, x + 2)); if (!is_missing(x) && !isinf(x)) { results["logsub"].append(logsub(x, x - 1)); results["dilogarithm"].append(dilogarithm(x)); results["fasttanh"].append(fasttanh(x)); results["fastsigmoid"].append(fastsigmoid(x)); results["ultrafasttanh"].append(ultrafasttanh(x)); results["ultrafastsigmoid"].append(ultrafastsigmoid(x)); results["tabulated_softplus"].append(tabulated_softplus(x)); results["tabulated_soft_slope"].append(tabulated_soft_slope(x)); } else { results["logsub"].append(0); results["dilogarithm"].append(0); results["fasttanh"].append(0); results["fastsigmoid"].append(0); results["ultrafasttanh"].append(0); results["ultrafastsigmoid"].append(0); results["tabulated_softplus"].append(0); results["tabulated_soft_slope"].append(0); } if (FABS(x) < 100) { results["softplus_primitive"].append(softplus_primitive(x)); results["tabulated_softplus_primitive"].append(tabulated_softplus_primitive(x)); results["hard_slope_integral"].append(hard_slope_integral(x)); results["soft_slope_integral"].append(soft_slope_integral(x)); results["tabulated_soft_slope_integral"].append(tabulated_soft_slope_integral(x)); } else { results["softplus_primitive"].append(0); results["tabulated_softplus_primitive"].append(0); results["hard_slope_integral"].append(0); results["soft_slope_integral"].append(0); results["tabulated_soft_slope_integral"].append(0); } if (pb) pb->update(i + 1); } }
Reimplemented from PLearn::PTest.
Definition at line 86 of file PLMathTest.h.
map<string, Vec> PLearn::PLMathTest::results |
Definition at line 68 of file PLMathTest.h.
Referenced by declareOptions().