PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <TMatTest.h>
Public Member Functions | |
TMatTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TMatTest * | 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 | |
real | bound |
int | mat_length |
int | mat_width |
int | vec_length |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Protected Attributes | |
map< string, Mat > | mat_options |
map< string, real > | real_options |
map< string, Vec > | vec_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 TMatTest.h.
typedef PTest PLearn::TMatTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file TMatTest.h.
PLearn::TMatTest::TMatTest | ( | ) |
Default constructor.
Definition at line 61 of file TMatTest.cc.
: bound(10), mat_length(2), mat_width(3), vec_length(10) {}
string PLearn::TMatTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
OptionList & PLearn::TMatTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
RemoteMethodMap & PLearn::TMatTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
Object * PLearn::TMatTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
StaticInitializer TMatTest::_static_initializer_ & PLearn::TMatTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
void PLearn::TMatTest::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 71 of file TMatTest.cc.
References PLearn::PTest::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::TMatTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 134 of file TMatTest.cc.
Referenced by build().
{ // ### 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::TMatTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
void PLearn::TMatTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 97 of file TMatTest.cc.
References bound, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::PTest::declareOptions(), PLearn::OptionBase::learntoption, mat_length, mat_options, mat_width, real_options, vec_length, and vec_options.
{ declareOption(ol, "vec_length", &TMatTest::vec_length, OptionBase::buildoption, "Length of the vector on which the TMat functions are to be applied."); declareOption(ol, "mat_length", &TMatTest::mat_length, OptionBase::buildoption, "Length of the matrix on which the TMat functions are to be applied."); declareOption(ol, "mat_width", &TMatTest::mat_width, OptionBase::buildoption, "Width of the matrix on which the TMat functions are to be applied."); declareOption(ol, "bound", &TMatTest::bound, OptionBase::buildoption, "Bound for the (real) values sampled in the vector."); declareOption(ol, "mat_options", &TMatTest::mat_options, OptionBase::learntoption, "Matrices."); declareOption(ol, "real_options", &TMatTest::real_options, OptionBase::learntoption, "Real numbers"); declareOption(ol, "vec_options", &TMatTest::vec_options, OptionBase::learntoption, "Vectors"); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::TMatTest::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PTest.
Definition at line 93 of file TMatTest.h.
:
//##### Protected Options ###############################################
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
OptionList & PLearn::TMatTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
OptionMap & PLearn::TMatTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
RemoteMethodMap & PLearn::TMatTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 56 of file TMatTest.cc.
void PLearn::TMatTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 80 of file TMatTest.cc.
References PLearn::PTest::makeDeepCopyFromShallowCopy(), and 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("TMatTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::TMatTest::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 148 of file TMatTest.cc.
References PLearn::argmax(), PLearn::argmin(), bound, PLearn::PRandom::common(), PLearn::TMat< T >::copy(), PLearn::TVec< T >::copy(), PLearn::endl(), PLearn::exp(), PLearn::fasttanh(), PLearn::TMat< T >::fill(), PLearn::TVec< T >::fill(), PLearn::flush(), PLearn::harmonic_mean(), PLearn::inverted(), PLearn::log(), PLearn::logadd(), mat_length, mat_options, mat_width, PLearn::max(), PLearn::mean(), PLearn::median(), PLearn::min(), PLearn::multiplyAcc(), PLearn::nonZeroIndices(), PLearn::norm(), PLASSERT, PLearn::pout, PLearn::product(), PLearn::productAcc(), real_options, PLearn::remove_missing(), PLearn::sign(), PLearn::softmax(), PLearn::sqrt(), PLearn::square(), PLearn::squareroot(), PLearn::sum(), PLearn::sum_of_log(), PLearn::sumabs(), PLearn::sumsquare(), PLearn::tanh(), vec_length, and vec_options.
{ PLASSERT( vec_length > 0 ); // TODO Make it work with vec_length == 0 PLASSERT( bound > 0 ); Vec vec( vec_length ); PRandom::common(false)->fill_random_uniform(vec, -bound, bound); Mat mat(mat_length, mat_width); PRandom::common(false)->fill_random_uniform(mat, -bound, bound); pout << "Starting TMatTest with vector of length " << vec_length << " and matrix of size (" << mat_length << " x " << mat_width << ")" << flush; this->vec_options["vector"] = vec; this->vec_options ["sign"] = sign ( vec ); this->real_options["sum"] = sum ( vec ); this->real_options["sum (ignore missing)"] = sum ( vec, true ); this->real_options["sumabs"] = sumabs ( vec ); this->real_options["sumsquare"] = sumsquare ( vec ); this->real_options["sum_of_log"] = sum_of_log ( vec ); this->real_options["product"] = product ( vec ); this->real_options["mean"] = mean ( vec ); this->real_options["mean (ignore missing)"] = mean ( vec, true ); this->real_options["harmonic_mean"] = harmonic_mean ( vec ); this->real_options["harmonic_mean (ignore_missing)"] = harmonic_mean ( vec, true ); this->real_options["min"] = min ( vec ); this->real_options["argmin"] = argmin ( vec ); this->real_options["max"] = max ( vec ); this->real_options["argmax"] = argmax ( vec ); this->real_options["norm"] = norm ( vec ); this->vec_options ["log"] = log ( vec ); this->vec_options ["sqrt"] = sqrt ( vec ); this->vec_options ["tanh"] = tanh ( vec ); this->vec_options ["fasttanh"] = fasttanh ( vec ); this->vec_options ["inverted"] = inverted ( vec ); this->vec_options ["square"] = square ( vec ); this->vec_options ["squareroot"] = squareroot ( vec ); this->vec_options ["remove_missing"] = remove_missing( vec ); this->vec_options ["softmax"] = softmax ( vec ); this->vec_options ["exp"] = exp ( vec ); this->vec_options ["nonZeroIndices"] = nonZeroIndices( vec ); this->real_options["logadd"] = logadd ( vec ); this->real_options["median"] = median ( vec ); Vec scaled_vec = vec.copy(); scaled_vec *= scaled_vec[0]; this->vec_options["operator*=_vec"] = scaled_vec; Vec multiply_acc_vec = vec.copy(); multiplyAcc(multiply_acc_vec, vec, -scaled_vec[0]); this->vec_options["multiplyAcc_vec"] = multiply_acc_vec; Mat scaled_mat = mat.copy(); scaled_mat *= scaled_mat(0, 0); this->mat_options["operator*=_mat"] = scaled_mat; Mat multiply_acc_mat = mat.copy(); multiplyAcc(multiply_acc_mat, mat, -scaled_mat(0, 0)); this->mat_options["multiplyAcc_mat"] = multiply_acc_mat; // Now test a specific case where problems can occur: the multiplication of // a matrix (m x 0) by a vector of size 0. The result must be a vector of // size m, filled with 0. Vec vec_result(2, 1); Mat mat_m_by_zero(2, 0); Vec vec_zero; product(vec_result, mat_m_by_zero, vec_zero); this->vec_options["product_empty_matrix_by_empty_vector"] = vec_result.copy(); // Similar but with accumulation. vec_result.fill(1); productAcc(vec_result, mat_m_by_zero, vec_zero); this->vec_options["product_empty_matrix_by_empty_vector_acc"] = vec_result; // Similar tests with matrices. Mat mat_result(2, 1, 1); Mat mat_zero(0, 1); product(mat_result, mat_m_by_zero, mat_zero); this->mat_options["product_empty_matrix_by_empty_matrix"] = mat_result.copy(); mat_result.fill(1); productAcc(mat_result, mat_m_by_zero, mat_zero); this->mat_options["product_empty_matrix_by_empty_matrix_acc"] = mat_result; pout << "... DONE!" << endl; }
Reimplemented from PLearn::PTest.
Definition at line 93 of file TMatTest.h.
Definition at line 72 of file TMatTest.h.
Referenced by declareOptions(), and perform().
Definition at line 73 of file TMatTest.h.
Referenced by declareOptions(), and perform().
map<string, Mat> PLearn::TMatTest::mat_options [protected] |
Definition at line 114 of file TMatTest.h.
Referenced by declareOptions(), and perform().
Definition at line 74 of file TMatTest.h.
Referenced by declareOptions(), and perform().
map<string, real> PLearn::TMatTest::real_options [protected] |
Definition at line 115 of file TMatTest.h.
Referenced by declareOptions(), and perform().
Definition at line 75 of file TMatTest.h.
Referenced by declareOptions(), and perform().
map<string, Vec> PLearn::TMatTest::vec_options [protected] |
Definition at line 116 of file TMatTest.h.
Referenced by declareOptions(), and perform().