#include <StackedLearner.h>
Inheritance diagram for PLearn::StackedLearner:
Public Types | |
typedef PLearner | inherited |
Public Member Functions | |
StackedLearner () | |
void | setTrainStatsCollector (PP< VecStatsCollector > statscol) |
Sets the statistics collector whose update() method will be called during training. | |
virtual void | build () |
simply calls inherited::build() then build_() | |
virtual void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
Transforms a shallow copy into a deep copy. | |
PLEARN_DECLARE_OBJECT (StackedLearner) | |
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< string > | getTestCostNames () const |
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method). | |
virtual TVec< 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 void | setTrainingSet (VMat training_set, bool call_forget=true) |
Declares the train_set Then calls build() and forget() if necessary. | |
Public Attributes | |
TVec< PP< PLearner > > | base_learners |
A set of 1st level base learners that are independently trained (here or elsewhere) and whose outputs will serve as inputs to the combiner. | |
PP< PLearner > | combiner |
A learner that is trained (possibly on a data set different from the one used to train the base_learners) using the outputs of the base_learners as inputs. | |
PP< Splitter > | splitter |
This can be and which data subset(s) goes to training the combiner. | |
PP< Splitter > | base_train_splitter |
This can be used to split the training set into different training sets for each base learner. | |
bool | train_base_learners |
whether to train the base learners in the method train (otherwise they should be initialized at construction / setOption time) | |
bool | normalize_base_learners_output |
If set to 1, the output of the base learners on the combiner training set will be normalized (zero mean, unit variance). | |
bool | precompute_base_learners_output |
If set to 1, the output of the base learners on the combiner training set will be precomputed in memory before training the combiner. | |
bool | put_raw_input |
optionally put the raw input as additional input of the combiner | |
bool | put_costs |
optionally put the costs of all the learners as additional inputs of the combiner (NB: this option actually isn't implemented yet) | |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Protected Attributes | |
Mat | base_learners_outputs |
Private Member Functions | |
void | build_ () |
This does the actual building. |
|
Reimplemented from PLearn::PLearner. Definition at line 67 of file StackedLearner.h. |
|
Definition at line 51 of file StackedLearner.cc. |
|
simply calls inherited::build() then build_()
Reimplemented from PLearn::PLearner. Definition at line 159 of file StackedLearner.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::PLearner. Definition at line 132 of file StackedLearner.cc. References base_learners, base_learners_outputs, combiner, PLearn::TVec< PP< PLearner > >::length(), PLERROR, PLearn::TMat< T >::resize(), and splitter. Referenced by build(). |
|
Computes the costs from already computed output.
Implements PLearn::PLearner. Definition at line 293 of file StackedLearner.cc. References base_learners, base_learners_outputs, combiner, and PLearn::TMat< T >::toVec(). |
|
Computes the output from the input.
Implements PLearn::PLearner. Definition at line 278 of file StackedLearner.cc. References base_learners, base_learners_outputs, PLearn::columnMean(), combiner, PLearn::TVec< PP< PLearner > >::length(), PLERROR, PLearn::TMat< T >::toVec(), and PLearn::Vec. |
|
Declares this class' options.
Reimplemented from PLearn::PLearner. Definition at line 75 of file StackedLearner.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!)
Implements PLearn::PLearner. Definition at line 190 of file StackedLearner.cc. References base_learners, combiner, PLearn::TVec< PP< PLearner > >::length(), and train_base_learners. |
|
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).
Implements PLearn::PLearner. Definition at line 302 of file StackedLearner.cc. References base_learners, and combiner. |
|
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 312 of file StackedLearner.cc. References base_learners, and combiner. |
|
Transforms a shallow copy into a deep copy.
Definition at line 166 of file StackedLearner.cc. References base_learners, base_train_splitter, combiner, PLearn::deepCopyField(), and splitter. |
|
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 180 of file StackedLearner.cc. References base_learners, and combiner. |
|
|
|
Declares the train_set Then calls build() and forget() if necessary.
Reimplemented from PLearn::PLearner. Definition at line 199 of file StackedLearner.cc. References base_learners, base_train_splitter, combiner, PLearn::TVec< PP< PLearner > >::length(), PLERROR, put_raw_input, splitter, and train_base_learners. |
|
Sets the statistics collector whose update() method will be called during training. Note: You shouldn't have to overload this in subclasses, except maybe to forward the call to an underlying learner. Reimplemented from PLearn::PLearner. Definition at line 125 of file StackedLearner.cc. References combiner. |
|
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 239 of file StackedLearner.cc. References base_learners, combiner, PLearn::TVec< PP< PLearner > >::length(), normalize_base_learners_output, PLERROR, PLearn::VMat::precompute(), precompute_base_learners_output, splitter, PLearn::tostring(), and train_base_learners. |
|
A set of 1st level base learners that are independently trained (here or elsewhere) and whose outputs will serve as inputs to the combiner.
Definition at line 78 of file StackedLearner.h. Referenced by build_(), computeCostsFromOutputs(), computeOutput(), forget(), getTestCostNames(), getTrainCostNames(), makeDeepCopyFromShallowCopy(), outputsize(), setTrainingSet(), and train(). |
|
Definition at line 63 of file StackedLearner.h. Referenced by build_(), computeCostsFromOutputs(), and computeOutput(). |
|
This can be used to split the training set into different training sets for each base learner. If it is not set, the same training set will be applied to the base learners. Definition at line 92 of file StackedLearner.h. Referenced by makeDeepCopyFromShallowCopy(), and setTrainingSet(). |
|
A learner that is trained (possibly on a data set different from the one used to train the base_learners) using the outputs of the base_learners as inputs.
Definition at line 83 of file StackedLearner.h. Referenced by build_(), computeCostsFromOutputs(), computeOutput(), forget(), getTestCostNames(), getTrainCostNames(), makeDeepCopyFromShallowCopy(), outputsize(), setTrainingSet(), setTrainStatsCollector(), and train(). |
|
If set to 1, the output of the base learners on the combiner training set will be normalized (zero mean, unit variance).
Definition at line 100 of file StackedLearner.h. Referenced by train(). |
|
If set to 1, the output of the base learners on the combiner training set will be precomputed in memory before training the combiner.
Definition at line 104 of file StackedLearner.h. Referenced by train(). |
|
optionally put the costs of all the learners as additional inputs of the combiner (NB: this option actually isn't implemented yet)
Definition at line 111 of file StackedLearner.h. |
|
optionally put the raw input as additional input of the combiner
Definition at line 107 of file StackedLearner.h. Referenced by setTrainingSet(). |
|
This can be and which data subset(s) goes to training the combiner.
Definition at line 87 of file StackedLearner.h. Referenced by build_(), makeDeepCopyFromShallowCopy(), setTrainingSet(), and train(). |
|
whether to train the base learners in the method train (otherwise they should be initialized at construction / setOption time)
Definition at line 96 of file StackedLearner.h. Referenced by forget(), setTrainingSet(), and train(). |