#include <EmbeddedLearner.h>
Inheritance diagram for PLearn::EmbeddedLearner:


| Public Types | |
| typedef PLearner | inherited | 
| Public Member Functions | |
| EmbeddedLearner () | |
| virtual void | build () | 
| **** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_() | |
| virtual void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) | 
| Transforms a shallow copy into a deep copy. | |
| PLEARN_DECLARE_OBJECT (EmbeddedLearner) | |
| Declares name and deepCopy methods. | |
| virtual int | inputsize () const | 
| Default returns train_set->inputsize(). | |
| virtual int | targetsize () const | 
| Default returns train_set->targetsize(). | |
| virtual int | outputsize () const | 
| SUBCLASS WRITING: overload this so that it returns the size of this learner's output, as a function of 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 stats with training costs measured on-line in the process. | |
| virtual void | test (VMat testset, PP< VecStatsCollector > test_stats, VMat testoutputs=0, VMat testcosts=0) const | 
| Override the test method to forward to embedded learner's test method. | |
| 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. | |
| 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 TVec< string > | getTestCostNames () const | 
| *** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus | |
| virtual TVec< string > | getTrainCostNames () const | 
| *** SUBCLASS WRITING: *** This should return the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats | |
| Public Attributes | |
| PP< PLearner > | learner_ | 
| Static Protected Member Functions | |
| void | declareOptions (OptionList &ol) | 
| Declares this class' options. | |
| Private Member Functions | |
| void | build_ () | 
| This does the actual building. | |
| 
 | 
| 
 Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 59 of file EmbeddedLearner.h. | 
| 
 | 
| 
 Definition at line 53 of file EmbeddedLearner.cc. | 
| 
 | 
| **** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_() 
 Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 71 of file EmbeddedLearner.cc. References build_(). | 
| 
 | 
| This does the actual building. 
 Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 63 of file EmbeddedLearner.cc. References learner_, and PLERROR. 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::SelectInputSubsetLearner. Definition at line 104 of file EmbeddedLearner.cc. References learner_. | 
| 
 | ||||||||||||||||
| 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. Definition at line 116 of file EmbeddedLearner.cc. References learner_. | 
| 
 | ||||||||||||
| *** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input 
 Implements PLearn::PLearner. Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 99 of file EmbeddedLearner.cc. References learner_, and PLearn::Vec. | 
| 
 | ||||||||||||||||||||
| 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::SelectInputSubsetLearner. Definition at line 110 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| Declares this class' options. 
 Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 56 of file EmbeddedLearner.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. Definition at line 78 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| *** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus 
 Implements PLearn::PLearner. Definition at line 119 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| *** SUBCLASS WRITING: *** This should return 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 122 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| Default returns train_set->inputsize(). 
 Reimplemented from PLearn::PLearner. Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 81 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| Transforms a shallow copy into a deep copy. 
 Reimplemented in PLearn::SelectInputSubsetLearner. Definition at line 125 of file EmbeddedLearner.cc. References PLearn::deepCopyField(), and learner_. | 
| 
 | 
| SUBCLASS WRITING: overload this so that it returns the size of this learner's output, as a function of its inputsize(), targetsize() and set options. 
 Implements PLearn::PLearner. Definition at line 87 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| Declares name and deepCopy methods. 
 | 
| 
 | 
| Default returns train_set->targetsize(). 
 Reimplemented from PLearn::PLearner. Definition at line 84 of file EmbeddedLearner.cc. References learner_. | 
| 
 | ||||||||||||||||||||
| Override the test method to forward to embedded learner's test method. 
 Reimplemented from PLearn::PLearner. Definition at line 93 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| The role of the train method is to bring the learner up to stage==nstages, updating the stats with training costs measured on-line in the process. *** SUBCLASS WRITING: *** 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(); if(nstages<stage) // asking to revert to a previous stage! forget(); // reset the learner to stage=0 while(stage<nstages) { clear statistics of previous epoch train_stats->forget(); ... train for 1 stage, and update train_stats, using train_set->getSample(input, target, weight); and train_stats->update(train_costs) ++stage; train_stats->finalize(); // finalize statistics for this epoch } Implements PLearn::PLearner. Definition at line 90 of file EmbeddedLearner.cc. References learner_. | 
| 
 | 
| 
 Definition at line 56 of file EmbeddedLearner.h. Referenced by build_(), computeCostsFromOutputs(), computeCostsOnly(), computeOutput(), computeOutputAndCosts(), forget(), getTestCostNames(), getTrainCostNames(), inputsize(), makeDeepCopyFromShallowCopy(), outputsize(), targetsize(), test(), and train(). | 
 1.3.7
 1.3.7