PLearn 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions
PLearn::VarUtilsTest Class Reference

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <VarUtilsTest.h>

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

List of all members.

Public Member Functions

 VarUtilsTest ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual VarUtilsTestdeepCopy (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 PPathdeclaringFile ()

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Protected Attributes

map< string, Matmat_results

Private Types

typedef PTest inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

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

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 62 of file VarUtilsTest.h.


Member Typedef Documentation

Reimplemented from PLearn::PTest.

Definition at line 64 of file VarUtilsTest.h.


Constructor & Destructor Documentation

PLearn::VarUtilsTest::VarUtilsTest ( )

Default constructor.

Definition at line 61 of file VarUtilsTest.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)
}

Member Function Documentation

string PLearn::VarUtilsTest::_classname_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

OptionList & PLearn::VarUtilsTest::_getOptionList_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

RemoteMethodMap & PLearn::VarUtilsTest::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

bool PLearn::VarUtilsTest::_isa_ ( const Object o) [static]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

Object * PLearn::VarUtilsTest::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

StaticInitializer VarUtilsTest::_static_initializer_ & PLearn::VarUtilsTest::_static_initialize_ ( ) [static]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

void PLearn::VarUtilsTest::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 74 of file VarUtilsTest.cc.

void PLearn::VarUtilsTest::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::PTest.

Definition at line 113 of file VarUtilsTest.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::VarUtilsTest::classname ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

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

Declares the class options.

Reimplemented from PLearn::PTest.

Definition at line 100 of file VarUtilsTest.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), and mat_results.

{
    declareOption(ol, "mat_results", &VarUtilsTest::mat_results,
        OptionBase::buildoption,
        "Test Mat results.");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

static const PPath& PLearn::VarUtilsTest::declaringFile ( ) [inline, static]

Reimplemented from PLearn::PTest.

Definition at line 89 of file VarUtilsTest.h.

:
    //#####  Protected Options  ###############################################
VarUtilsTest * PLearn::VarUtilsTest::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

OptionList & PLearn::VarUtilsTest::getOptionList ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

OptionMap & PLearn::VarUtilsTest::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

RemoteMethodMap & PLearn::VarUtilsTest::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 56 of file VarUtilsTest.cc.

void PLearn::VarUtilsTest::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PTest.

Definition at line 83 of file VarUtilsTest.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("VarUtilsTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}
void PLearn::VarUtilsTest::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 127 of file VarUtilsTest.cc.

References PLearn::PRandom::common(), PLearn::distance(), PLearn::entropy(), PLearn::VarArray::fprop(), PLearn::mean(), PLearn::neg_log_pi(), PLearn::norm(), PLearn::powdistance(), PLearn::pownorm(), PLearn::propagationPath(), and PLearn::softmax().

{
    int var_length = 10;
    int var_width = 5;
    int bound = 10;
    Var tmp;
    VarArray prop_path;
    Var mat_var(var_length, var_width);
    Var vec_var(var_length, 1);
    Var prob_mat_var(var_length, var_width);
    Var prob_vec_var(var_length, 1);
    Var scalar_var(1, 1);
    Var multi_index_var(var_width, 1);
    multi_index_var->matValue << "1 3 5 2 9";
    Var single_index_var(1, 1);
    single_index_var->matValue(0, 0) = 3;
    PRandom::common(false)->fill_random_uniform(mat_var->matValue, -bound, bound);
    PRandom::common(false)->fill_random_uniform(vec_var->matValue, -bound, bound);
    PRandom::common(false)->fill_random_uniform(prob_mat_var->matValue, 0, 1);
    PRandom::common(false)->fill_random_uniform(prob_vec_var->matValue, 0, 1);
    PRandom::common(false)->fill_random_uniform(scalar_var->matValue, -bound, bound);

    tmp = mean(mat_var);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["mean"] = tmp->matValue;

    tmp = neg_log_pi(prob_vec_var, single_index_var);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["neg_log_pi_vec"] = tmp->matValue;

    tmp = neg_log_pi(prob_mat_var, multi_index_var);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["neg_log_pi_mat"] = tmp->matValue;

    tmp = softmax(prob_vec_var, 2);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["softmax"] = tmp->matValue;

    tmp = pownorm(vec_var, 1.5);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["pownorm"] = tmp->matValue;

    tmp = norm(vec_var, 1.5);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["norm"] = tmp->matValue;

    tmp = entropy(vec_var);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["entropy"] = tmp->matValue;

    tmp = distance(vec_var, prob_vec_var, 2);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["distance"] = tmp->matValue;

    tmp = powdistance(vec_var, prob_vec_var, 2);
    prop_path = propagationPath(tmp);
    prop_path.fprop();
    mat_results["powdistance"] = tmp->matValue;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::PTest.

Definition at line 89 of file VarUtilsTest.h.

map<string, Mat> PLearn::VarUtilsTest::mat_results [protected]

Definition at line 107 of file VarUtilsTest.h.

Referenced by declareOptions().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines