#include <SequentialLearner.h>
Inheritance diagram for PLearn::SequentialLearner:
Public Types | |
typedef PLearner | inherited |
Public Member Functions | |
int | get_last_train_t () |
last value of test_set.length() for which testing was actually done | |
int | get_last_call_train_t () |
int | get_last_test_t () |
SequentialLearner () | |
Constructor. | |
virtual void | build () |
simply calls inherited::build() then build_() | |
virtual int | outputsize () const |
Returns train_set->targetsize(). | |
virtual int | nTestCosts () const |
Caches getTestCostNames().size() in an internal variable the first time it is called, and then returns the content of this variable. | |
virtual void | setTrainingSet (VMat training_set, bool call_forget=true) |
Declares the train_set Then calls build() and forget() if necessary Note: You shouldn't have to overload this in subclasses, except in maybe to forward the call to an underlying learner. | |
virtual void | train ()=0 |
virtual void | test (VMat testset, PP< VecStatsCollector > test_stats, VMat testoutputs=0, VMat testcosts=0) const =0 |
virtual void | computeOutputAndCosts (const Vec &input, const Vec &target, Vec &output, Vec &costs) const |
Default calls computeOutput and computeCostsFromOutputs You may overload this if you have a more efficient way to compute both output and weighted costs at the same time. | |
virtual void | computeCostsOnly (const Vec &input, const Vec &target, Vec &costs) const |
Default calls computeOutputAndCosts This may be overloaded if there is a more efficient way to compute the costs directly, without computing the whole output vector. | |
virtual void | computeOutput (const Vec &input, Vec &output) const |
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input | |
virtual void | computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const |
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the weighted costs from already computed output. | |
int | sequenceStart () const |
int | sequenceLength () const |
Vec | getCostSequence (int cost_index) const |
Vec | getCostSequence (string cname) const |
virtual void | matlabSave (const string &matlab_subdir) |
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!) | |
PLEARN_DECLARE_ABSTRACT_OBJECT (SequentialLearner) | |
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Public Attributes | |
int | init_train_size |
int | max_seq_len |
max length of the VMat that train can contain = max de t ci-haut | |
int | max_train_len |
max nb of (input,target) pairs actually used for training | |
int | train_step |
how often we have to re-train a model, (default = 1 = after every time step) | |
int | horizon |
by how much to offset the target columns wrt the input columns (default = 1) | |
int | outputsize_ |
Mat | predictions |
these two fields are used by other classes such as SequentialModelSelector and SequentialValidation and they are filled when the method test is called | |
Mat | errors |
initial values may be 'missing value' | |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declare this class' options. | |
Protected Attributes | |
int | last_train_t |
int | last_call_train_t |
last value of train_set.length() for which training was actually done (<= last_call_train_t) | |
int | last_test_t |
last value of train_set.length() for which train() was called (may not have done anything) | |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 57 of file SequentialLearner.h.
|
Reimplemented from PLearn::PLearner. Reimplemented in PLearn::MovingAverage, and PLearn::SequentialModelSelector. Definition at line 60 of file SequentialLearner.h. |
|
Constructor.
Definition at line 46 of file SequentialLearner.cc. |
|
simply calls inherited::build() then build_()
Reimplemented from PLearn::PLearner. Reimplemented in PLearn::EmbeddedSequentialLearner, PLearn::MovingAverage, and PLearn::SequentialModelSelector. Definition at line 78 of file SequentialLearner.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::PLearner. Reimplemented in PLearn::EmbeddedSequentialLearner, PLearn::MovingAverage, and PLearn::SequentialModelSelector. Definition at line 59 of file SequentialLearner.cc. References errors, PLearn::TMat< T >::fill(), max_seq_len, MISSING_VALUE, nTestCosts(), outputsize(), PLERROR, predictions, and PLearn::TMat< T >::resize(). Referenced by build(). |
|
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the weighted costs from already computed output. The costs should correspond to the cost names returned by getTestCostNames() NOTE: In exotic cases, the cost may also depend on some info in the input, that's why the method also gets so see it. Implements PLearn::PLearner. Reimplemented in PLearn::MovingAverage, and PLearn::SequentialModelSelector. Definition at line 154 of file SequentialLearner.cc. References PLERROR. |
|
Default calls computeOutputAndCosts This may be overloaded if there is a more efficient way to compute the costs directly, without computing the whole output vector.
Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SequentialModelSelector. Definition at line 147 of file SequentialLearner.cc. References PLERROR. |
|
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input
Implements PLearn::PLearner. Reimplemented in PLearn::SequentialModelSelector. Definition at line 151 of file SequentialLearner.cc. References PLERROR. |
|
Default calls computeOutput and computeCostsFromOutputs You may overload this if you have a more efficient way to compute both output and weighted costs at the same time.
Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SequentialModelSelector. Definition at line 143 of file SequentialLearner.cc. References PLERROR, and PLearn::Vec. |
|
Declare this class' options.
Reimplemented from PLearn::PLearner. Reimplemented in PLearn::EmbeddedSequentialLearner, PLearn::MovingAverage, and PLearn::SequentialModelSelector. Definition at line 84 of file SequentialLearner.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
(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!) *** SUBCLASS WRITING: *** A typical forget() method should do the following:
Implements PLearn::PLearner. Reimplemented in PLearn::EmbeddedSequentialLearner, PLearn::MovingAverage, and PLearn::SequentialModelSelector. Definition at line 125 of file SequentialLearner.cc. References errors, PLearn::TMat< T >::fill(), PLearn::TMat< T >::isNotEmpty(), last_call_train_t, last_test_t, last_train_t, MISSING_VALUE, and predictions. Referenced by setTrainingSet(). |
|
Definition at line 69 of file SequentialLearner.h. References last_call_train_t. |
|
Definition at line 70 of file SequentialLearner.h. References last_test_t. |
|
last value of test_set.length() for which testing was actually done
Definition at line 68 of file SequentialLearner.h. References last_train_t. |
|
Definition at line 155 of file SequentialLearner.h. |
|
Definition at line 153 of file SequentialLearner.h. References errors, getCostSequence(), sequenceLength(), sequenceStart(), and PLearn::TMat< T >::subMat(). Referenced by getCostSequence(), and matlabSave(). |
|
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. Typical implementation: void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { SUPERCLASS_OF_THIS::makeDeepCopyFromShallowCopy(copies); member_ptr = member_ptr->deepCopy(copies); member_smartptr = member_smartptr->deepCopy(copies); member_mat.makeDeepCopyFromShallowCopy(copies); member_vec.makeDeepCopyFromShallowCopy(copies); ... } Reimplemented from PLearn::PLearner. Reimplemented in PLearn::EmbeddedSequentialLearner, and PLearn::SequentialModelSelector. Definition at line 52 of file SequentialLearner.cc. References PLearn::CopiesMap, PLearn::deepCopyField(), errors, and predictions. |
|
Any SequentialLearner will have the possiblity to save some data in a matlab 'readable' format. The data will be saved in expdir/matlab_subdir through the global matlabSave function (MatIO.h). Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SequentialModelSelector. Definition at line 158 of file SequentialLearner.cc. References PLearn::add(), PLearn::append_slash(), getCostSequence(), PLearn::PLearner::getExperimentDirectory(), PLearn::PLearner::getTestCostNames(), PLearn::TVec< T >::length(), PLearn::matlabSave(), predictions, and sequenceStart(). |
|
Caches getTestCostNames().size() in an internal variable the first time it is called, and then returns the content of this variable.
Reimplemented from PLearn::PLearner. Definition at line 140 of file SequentialLearner.cc. References PLearn::PLearner::getTestCostNames(), and PLearn::TVec< string >::size(). Referenced by build_(), and PLearn::EmbeddedSequentialLearner::test(). |
|
Returns train_set->targetsize().
Implements PLearn::PLearner. Definition at line 137 of file SequentialLearner.cc. References outputsize_. Referenced by build_(), PLearn::MovingAverage::test(), PLearn::EmbeddedSequentialLearner::test(), and PLearn::MovingAverage::train(). |
|
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
|
|
Definition at line 152 of file SequentialLearner.h. References init_train_size, and last_test_t. Referenced by getCostSequence(). |
|
The getCostSequence method returns the sequence of the cost at index 'cost_index' or named 'cname' from sequenceStart() with a length of sequenceLength(). Definition at line 151 of file SequentialLearner.h. References init_train_size. Referenced by getCostSequence(), and matlabSave(). |
|
Declares the train_set Then calls build() and forget() if necessary Note: You shouldn't have to overload this in subclasses, except in maybe to forward the call to an underlying learner.
Reimplemented from PLearn::PLearner. Definition at line 119 of file SequentialLearner.cc. References forget(). |
|
*** SUBCLASS WRITING: *** The method should:
Reimplemented from PLearn::PLearner. Implemented in PLearn::EmbeddedSequentialLearner, PLearn::MovingAverage, and PLearn::SequentialModelSelector. |
|
*** SUBCLASS WRITING: *** Does the actual training. Subclasses must implement this method. The method should upon entry, call setTrainingSet(training_set); The method should:
Implements PLearn::PLearner. Implemented in PLearn::EmbeddedSequentialLearner, PLearn::MovingAverage, and PLearn::SequentialModelSelector. |
|
initial values may be 'missing value'
Definition at line 89 of file SequentialLearner.h. Referenced by build_(), forget(), getCostSequence(), and makeDeepCopyFromShallowCopy(). |
|
by how much to offset the target columns wrt the input columns (default = 1)
Definition at line 82 of file SequentialLearner.h. |
|
Before the length of train_set reaches init_train_size, train doesn't do anything. Default: 1. Definition at line 78 of file SequentialLearner.h. Referenced by sequenceLength(), and sequenceStart(). |
|
last value of train_set.length() for which training was actually done (<= last_call_train_t)
Definition at line 64 of file SequentialLearner.h. Referenced by forget(), and get_last_call_train_t(). |
|
last value of train_set.length() for which train() was called (may not have done anything)
Definition at line 65 of file SequentialLearner.h. Referenced by forget(), get_last_test_t(), and sequenceLength(). |
|
Definition at line 63 of file SequentialLearner.h. Referenced by forget(), and get_last_train_t(). |
|
max length of the VMat that train can contain = max de t ci-haut
Definition at line 79 of file SequentialLearner.h. Referenced by build_(). |
|
max nb of (input,target) pairs actually used for training
Definition at line 80 of file SequentialLearner.h. |
|
Definition at line 83 of file SequentialLearner.h. Referenced by outputsize(). |
|
these two fields are used by other classes such as SequentialModelSelector and SequentialValidation and they are filled when the method test is called
Definition at line 87 of file SequentialLearner.h. Referenced by build_(), forget(), makeDeepCopyFromShallowCopy(), and matlabSave(). |
|
how often we have to re-train a model, (default = 1 = after every time step)
Definition at line 81 of file SequentialLearner.h. |