PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <TestLearner.h>
Public Member Functions | |
TestLearner () | |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //! | |
virtual int | outputsize () const |
Returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options). | |
virtual void | forget () |
(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) and sets 'stage' back to 0 (this is the stage of a fresh learner!). | |
virtual void | train () |
The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process. | |
virtual void | computeOutput (const Vec &input, Vec &output) const |
Computes the output from the input. | |
virtual void | computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const |
Computes the costs from already computed output. | |
virtual TVec< std::string > | getTestCostNames () const |
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method). | |
virtual TVec< std::string > | getTrainCostNames () const |
Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TestLearner * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Finish building the object; just call inherited::build followed by build_() | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
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 | |
std::string | dir_path |
Vec | train_costs |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef PLearner | 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 TestLearner.h.
typedef PLearner PLearn::TestLearner::inherited [private] |
Reimplemented from PLearn::PLearner.
Definition at line 63 of file TestLearner.h.
PLearn::TestLearner::TestLearner | ( | ) |
### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
Default constructor
Definition at line 54 of file TestLearner.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::TestLearner::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 52 of file TestLearner.cc.
OptionList & PLearn::TestLearner::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 52 of file TestLearner.cc.
RemoteMethodMap & PLearn::TestLearner::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 52 of file TestLearner.cc.
Reimplemented from PLearn::PLearner.
Definition at line 52 of file TestLearner.cc.
Object * PLearn::TestLearner::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 52 of file TestLearner.cc.
StaticInitializer TestLearner::_static_initializer_ & PLearn::TestLearner::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PLearner.
Definition at line 52 of file TestLearner.cc.
void PLearn::TestLearner::build | ( | ) | [virtual] |
Finish building the object; just call inherited::build followed by build_()
Reimplemented from PLearn::PLearner.
Definition at line 96 of file TestLearner.cc.
{ inherited::build(); build_(); }
void PLearn::TestLearner::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PLearner.
Definition at line 84 of file TestLearner.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::TestLearner::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file TestLearner.cc.
void PLearn::TestLearner::computeCostsFromOutputs | ( | const Vec & | input, |
const Vec & | output, | ||
const Vec & | target, | ||
Vec & | costs | ||
) | const [virtual] |
Computes the costs from already computed output.
Implements PLearn::PLearner.
Definition at line 175 of file TestLearner.cc.
References PLearn::TVec< T >::resize().
{
// Compute the costs from *already* computed output.
costs.resize(1) ;
costs[0] = 1 ;
}
Computes the output from the input.
Reimplemented from PLearn::PLearner.
Definition at line 166 of file TestLearner.cc.
References PLearn::TVec< T >::resize().
{ // Compute the output from the input. int nout = outputsize(); output.resize(nout); output[0] = 1 ; // ... }
void PLearn::TestLearner::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PLearner.
Definition at line 64 of file TestLearner.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), and dir_path.
{ // ### 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 // ### ex: // declareOption(ol, "myoption", &TestLearner::myoption, OptionBase::buildoption, // "Help text describing this option"); // ... // Now call the parent class' declareOptions declareOption(ol,"dir_path", &TestLearner::dir_path, OptionBase::buildoption, "The Path to the training data"); inherited::declareOptions(ol); }
static const PPath& PLearn::TestLearner::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PLearner.
Definition at line 140 of file TestLearner.h.
:
//##### Protected Options ###############################################
TestLearner * PLearn::TestLearner::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PLearner.
Definition at line 52 of file TestLearner.cc.
void PLearn::TestLearner::forget | ( | ) | [virtual] |
(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) and sets 'stage' back to 0 (this is the stage of a fresh learner!).
(Re-)initialize the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!)
A typical forget() method should do the following:
Reimplemented from PLearn::PLearner.
Definition at line 127 of file TestLearner.cc.
{ stage = 0 ; }
OptionList & PLearn::TestLearner::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file TestLearner.cc.
OptionMap & PLearn::TestLearner::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file TestLearner.cc.
RemoteMethodMap & PLearn::TestLearner::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 52 of file TestLearner.cc.
TVec< string > PLearn::TestLearner::getTestCostNames | ( | ) | const [virtual] |
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).
Implements PLearn::PLearner.
Definition at line 183 of file TestLearner.cc.
{ // Return the names of the costs computed by computeCostsFromOutpus // (these may or may not be exactly the same as what's returned by getTrainCostNames). // ... TVec<string> t(1) ; t[0] = "binary_class_error" ; return t ; }
TVec< string > PLearn::TestLearner::getTrainCostNames | ( | ) | const [virtual] |
Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.
Implements PLearn::PLearner.
Definition at line 193 of file TestLearner.cc.
{ TVec<string> t(1) ; t[0] = "binary_class_error" ; return t ; // Return the names of the objective costs that the train method computes and // for which it updates the VecStatsCollector train_stats // (these may or may not be exactly the same as what's returned by getTestCostNames). // ... }
void PLearn::TestLearner::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PLearner.
Definition at line 103 of file TestLearner.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("TestLearner::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
int PLearn::TestLearner::outputsize | ( | ) | const [virtual] |
Returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options).
Implements PLearn::PLearner.
Definition at line 120 of file TestLearner.cc.
{ // Compute and return the size of this learner's output (which typically // may depend on its inputsize(), targetsize() and set options). return 1 ; }
void PLearn::TestLearner::train | ( | ) | [virtual] |
The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.
Implements PLearn::PLearner.
Definition at line 141 of file TestLearner.cc.
{ // The role of the train method is to bring the learner up to stage==nstages, // updating train_stats with training costs measured on-line in the process. /* TYPICAL CODE: static Vec input // static so we don't reallocate/deallocate memory each time... static Vec target // (but be careful that static means shared!) input.resize(inputsize()) // the train_set's inputsize() target.resize(targetsize()) // the train_set's targetsize() real weight */ if (!train_stats) // make a default stats collector, in case there's none train_stats = new VecStatsCollector() ; train_costs.resize(1); train_costs[0] = 0 ; train_stats->update(train_costs) ; train_stats->finalize() ; // finalize statistics for this epoch }
Reimplemented from PLearn::PLearner.
Definition at line 140 of file TestLearner.h.
std::string PLearn::TestLearner::dir_path |
Definition at line 79 of file TestLearner.h.
Referenced by declareOptions().
Definition at line 80 of file TestLearner.h.