#include <AddCostToLearner.h>
Inheritance diagram for PLearn::AddCostToLearner:
Public Member Functions | |
AddCostToLearner () | |
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 (AddCostToLearner) | |
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 | setExperimentDirectory (const string &the_expdir) |
Overrridden to forward to the sub_learner. | |
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 | setTrainStatsCollector (PP< VecStatsCollector > statscol) |
Sets the statistics collector whose update() method will be called during training. | |
Public Attributes | |
bool | check_output_consistency |
int | combine_bag_outputs_method |
bool | compute_costs_on_bags |
TVec< string > | costs |
bool | force_output_to_target_interval |
real | from_max |
real | from_min |
bool | rescale_output |
bool | rescale_target |
PP< PLearner > | sub_learner |
real | to_max |
real | to_min |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Protected Attributes | |
Mat | bag_outputs |
Used to store the outputs of the sub_learner for each sample in a bag. | |
int | bag_size |
Used to count the number of instances in a bag. | |
VarArray | cross_entropy_prop |
Propagation path for the cross entropy cost. | |
Var | cross_entropy_var |
Variable giving the cross entropy cost. | |
Vec | desired_target |
Used to store the target when computing a cost. | |
real | fac |
A precomputed factor for faster mapping. | |
real | output_max |
Constraints on the output given the costs being computed. | |
real | output_min |
Var | output_var |
Its value is sub_learner_output[0]. | |
Vec | sub_learner_output |
Used to store the sub_learner_output. | |
Vec | sub_input |
Used to store the input given to the sub_learner, when it needs to be copied in a separate place. | |
Var | target_var |
Its value is desired_target[0]. | |
Private Types | |
typedef PLearner | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
Private Attributes | |
Vec | combined_output |
Global storage to save memory allocations. |
|
Reimplemented from PLearn::PLearner. Definition at line 57 of file AddCostToLearner.h. |
|
Definition at line 80 of file AddCostToLearner.cc. |
|
Simply calls inherited::build() then build_().
Reimplemented from PLearn::PLearner. Definition at line 155 of file AddCostToLearner.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::PLearner. Definition at line 164 of file AddCostToLearner.cc. References PLearn::accessElement(), bag_outputs, costs, PLearn::cross_entropy(), cross_entropy_prop, cross_entropy_var, desired_target, PLearn::endl(), fac, from_max, from_min, PLearn::TVec< string >::length(), PLearn::max(), PLearn::min(), output_max, output_min, output_var, PLERROR, PLearn::propagationPath(), REAL_MAX, rescale_output, rescale_target, PLearn::TVec< T >::resize(), PLearn::TMat< T >::resize(), sub_learner, sub_learner_output, target_var, to_max, to_min, and PLearn::var(). Referenced by build(). |
|
Computes the costs from already computed output.
Implements PLearn::PLearner. Definition at line 216 of file AddCostToLearner.cc. References PLearn::abs(), bag_outputs, bag_size, check_output_consistency, PLearn::TMat< T >::column(), combine_bag_outputs_method, combined_output, compute_costs_on_bags, cross_entropy_prop, cross_entropy_var, desired_target, fac, PLearn::TVec< T >::fill(), force_output_to_target_interval, PLearn::VarArray::fprop(), from_min, PLearn::TMat< T >::length(), PLearn::TVec< T >::length(), PLearn::max(), MISSING_VALUE, output_max, output_min, PLERROR, PLWARNING, PLearn::powdistance(), PLearn::pownorm(), rescale_output, rescale_target, PLearn::TVec< T >::resize(), PLearn::TMat< T >::resize(), sub_learner, sub_learner_output, PLearn::TVec< T >::subVec(), to_max, to_min, and PLearn::TMat< T >::width(). |
|
Computes the output from the input.
Implements PLearn::PLearner. Definition at line 380 of file AddCostToLearner.cc. References sub_learner. |
|
Declares this class' options.
Reimplemented from PLearn::PLearner. Definition at line 96 of file AddCostToLearner.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 388 of file AddCostToLearner.cc. References bag_size, and sub_learner. |
|
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).
Implements PLearn::PLearner. Definition at line 397 of file AddCostToLearner.cc. References PLearn::TVec< T >::append(), costs, PLearn::TVec< string >::length(), and sub_learner. |
|
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 412 of file AddCostToLearner.cc. References sub_learner. |
|
Transforms a shallow copy into a deep copy.
Definition at line 424 of file AddCostToLearner.cc. References bag_outputs, combined_output, costs, cross_entropy_prop, cross_entropy_var, PLearn::deepCopyField(), desired_target, output_var, sub_input, sub_learner, sub_learner_output, target_var, and PLearn::varDeepCopyField(). |
|
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 443 of file AddCostToLearner.cc. References sub_learner. |
|
|
|
Overrridden to forward to the sub_learner.
Reimplemented from PLearn::PLearner. Definition at line 191 of file AddCostToLearner.h. References sub_learner. |
|
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 451 of file AddCostToLearner.cc. References compute_costs_on_bags, PLearn::VMat::length(), PLERROR, sub_learner, and PLearn::VMat::width(). |
|
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 195 of file AddCostToLearner.h. References setTrainStatsCollector(), and sub_learner. Referenced by setTrainStatsCollector(). |
|
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 479 of file AddCostToLearner.cc. References sub_learner. |
|
Used to store the outputs of the sub_learner for each sample in a bag.
Definition at line 71 of file AddCostToLearner.h. Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Used to count the number of instances in a bag.
Definition at line 74 of file AddCostToLearner.h. Referenced by computeCostsFromOutputs(), and forget(). |
|
Definition at line 111 of file AddCostToLearner.h. Referenced by computeCostsFromOutputs(). |
|
Definition at line 112 of file AddCostToLearner.h. Referenced by computeCostsFromOutputs(). |
|
Global storage to save memory allocations.
Definition at line 60 of file AddCostToLearner.h. Referenced by computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 113 of file AddCostToLearner.h. Referenced by computeCostsFromOutputs(), and setTrainingSet(). |
|
Definition at line 114 of file AddCostToLearner.h. Referenced by build_(), getTestCostNames(), and makeDeepCopyFromShallowCopy(). |
|
Propagation path for the cross entropy cost.
Definition at line 77 of file AddCostToLearner.h. Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Variable giving the cross entropy cost.
Definition at line 80 of file AddCostToLearner.h. Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Used to store the target when computing a cost.
Definition at line 83 of file AddCostToLearner.h. Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
A precomputed factor for faster mapping.
Definition at line 86 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Definition at line 115 of file AddCostToLearner.h. Referenced by computeCostsFromOutputs(). |
|
Definition at line 116 of file AddCostToLearner.h. Referenced by build_(). |
|
Definition at line 117 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Constraints on the output given the costs being computed.
Definition at line 89 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Definition at line 90 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Its value is sub_learner_output[0].
Definition at line 93 of file AddCostToLearner.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 118 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Definition at line 119 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Used to store the input given to the sub_learner, when it needs to be copied in a separate place.
Definition at line 100 of file AddCostToLearner.h. Referenced by makeDeepCopyFromShallowCopy(). |
|
Definition at line 120 of file AddCostToLearner.h. Referenced by build_(), computeCostsFromOutputs(), computeOutput(), forget(), getTestCostNames(), getTrainCostNames(), makeDeepCopyFromShallowCopy(), outputsize(), setExperimentDirectory(), setTrainingSet(), setTrainStatsCollector(), and train(). |
|
Used to store the sub_learner_output.
Definition at line 96 of file AddCostToLearner.h. Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Its value is desired_target[0].
Definition at line 103 of file AddCostToLearner.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 121 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |
|
Definition at line 122 of file AddCostToLearner.h. Referenced by build_(), and computeCostsFromOutputs(). |