Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::AddCostToLearner Class Reference

#include <AddCostToLearner.h>

Inheritance diagram for PLearn::AddCostToLearner:

Inheritance graph
[legend]
Collaboration diagram for PLearn::AddCostToLearner:

Collaboration graph
[legend]
List of all members.

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< stringgetTestCostNames () const
 Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).

virtual TVec< stringgetTrainCostNames () 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< stringcosts
bool force_output_to_target_interval
real from_max
real from_min
bool rescale_output
bool rescale_target
PP< PLearnersub_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.


Member Typedef Documentation

typedef PLearner PLearn::AddCostToLearner::inherited [private]
 

Reimplemented from PLearn::PLearner.

Definition at line 57 of file AddCostToLearner.h.


Constructor & Destructor Documentation

PLearn::AddCostToLearner::AddCostToLearner  ) 
 

Definition at line 80 of file AddCostToLearner.cc.


Member Function Documentation

void PLearn::AddCostToLearner::build  )  [virtual]
 

Simply calls inherited::build() then build_().

Reimplemented from PLearn::PLearner.

Definition at line 155 of file AddCostToLearner.cc.

References build_().

void PLearn::AddCostToLearner::build_  )  [private]
 

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().

void PLearn::AddCostToLearner::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 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().

void PLearn::AddCostToLearner::computeOutput const Vec input,
Vec output
const [virtual]
 

Computes the output from the input.

Implements PLearn::PLearner.

Definition at line 380 of file AddCostToLearner.cc.

References sub_learner.

void PLearn::AddCostToLearner::declareOptions OptionList ol  )  [static, protected]
 

Declares this class' options.

Reimplemented from PLearn::PLearner.

Definition at line 96 of file AddCostToLearner.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::AddCostToLearner::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!).

Implements PLearn::PLearner.

Definition at line 388 of file AddCostToLearner.cc.

References bag_size, and sub_learner.

TVec< string > PLearn::AddCostToLearner::getTestCostNames  )  const [virtual]
 

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.

TVec< string > PLearn::AddCostToLearner::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 412 of file AddCostToLearner.cc.

References sub_learner.

void PLearn::AddCostToLearner::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

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().

int PLearn::AddCostToLearner::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 443 of file AddCostToLearner.cc.

References sub_learner.

PLearn::AddCostToLearner::PLEARN_DECLARE_OBJECT AddCostToLearner   ) 
 

virtual void PLearn::AddCostToLearner::setExperimentDirectory const string the_expdir  )  [inline, virtual]
 

Overrridden to forward to the sub_learner.

Reimplemented from PLearn::PLearner.

Definition at line 191 of file AddCostToLearner.h.

References sub_learner.

void PLearn::AddCostToLearner::setTrainingSet VMat  training_set,
bool  call_forget = true
[virtual]
 

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().

virtual void PLearn::AddCostToLearner::setTrainStatsCollector PP< VecStatsCollector statscol  )  [inline, virtual]
 

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().

void PLearn::AddCostToLearner::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 479 of file AddCostToLearner.cc.

References sub_learner.


Member Data Documentation

Mat PLearn::AddCostToLearner::bag_outputs [mutable, protected]
 

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().

int PLearn::AddCostToLearner::bag_size [mutable, protected]
 

Used to count the number of instances in a bag.

Definition at line 74 of file AddCostToLearner.h.

Referenced by computeCostsFromOutputs(), and forget().

bool PLearn::AddCostToLearner::check_output_consistency
 

Definition at line 111 of file AddCostToLearner.h.

Referenced by computeCostsFromOutputs().

int PLearn::AddCostToLearner::combine_bag_outputs_method
 

Definition at line 112 of file AddCostToLearner.h.

Referenced by computeCostsFromOutputs().

Vec PLearn::AddCostToLearner::combined_output [mutable, private]
 

Global storage to save memory allocations.

Definition at line 60 of file AddCostToLearner.h.

Referenced by computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy().

bool PLearn::AddCostToLearner::compute_costs_on_bags
 

Definition at line 113 of file AddCostToLearner.h.

Referenced by computeCostsFromOutputs(), and setTrainingSet().

TVec<string> PLearn::AddCostToLearner::costs
 

Definition at line 114 of file AddCostToLearner.h.

Referenced by build_(), getTestCostNames(), and makeDeepCopyFromShallowCopy().

VarArray PLearn::AddCostToLearner::cross_entropy_prop [mutable, protected]
 

Propagation path for the cross entropy cost.

Definition at line 77 of file AddCostToLearner.h.

Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy().

Var PLearn::AddCostToLearner::cross_entropy_var [protected]
 

Variable giving the cross entropy cost.

Definition at line 80 of file AddCostToLearner.h.

Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy().

Vec PLearn::AddCostToLearner::desired_target [protected]
 

Used to store the target when computing a cost.

Definition at line 83 of file AddCostToLearner.h.

Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy().

real PLearn::AddCostToLearner::fac [protected]
 

A precomputed factor for faster mapping.

Definition at line 86 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

bool PLearn::AddCostToLearner::force_output_to_target_interval
 

Definition at line 115 of file AddCostToLearner.h.

Referenced by computeCostsFromOutputs().

real PLearn::AddCostToLearner::from_max
 

Definition at line 116 of file AddCostToLearner.h.

Referenced by build_().

real PLearn::AddCostToLearner::from_min
 

Definition at line 117 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

real PLearn::AddCostToLearner::output_max [protected]
 

Constraints on the output given the costs being computed.

Definition at line 89 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

real PLearn::AddCostToLearner::output_min [protected]
 

Definition at line 90 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

Var PLearn::AddCostToLearner::output_var [protected]
 

Its value is sub_learner_output[0].

Definition at line 93 of file AddCostToLearner.h.

Referenced by build_(), and makeDeepCopyFromShallowCopy().

bool PLearn::AddCostToLearner::rescale_output
 

Definition at line 118 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

bool PLearn::AddCostToLearner::rescale_target
 

Definition at line 119 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

Vec PLearn::AddCostToLearner::sub_input [mutable, protected]
 

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().

PP<PLearner> PLearn::AddCostToLearner::sub_learner
 

Definition at line 120 of file AddCostToLearner.h.

Referenced by build_(), computeCostsFromOutputs(), computeOutput(), forget(), getTestCostNames(), getTrainCostNames(), makeDeepCopyFromShallowCopy(), outputsize(), setExperimentDirectory(), setTrainingSet(), setTrainStatsCollector(), and train().

Vec PLearn::AddCostToLearner::sub_learner_output [protected]
 

Used to store the sub_learner_output.

Definition at line 96 of file AddCostToLearner.h.

Referenced by build_(), computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy().

Var PLearn::AddCostToLearner::target_var [protected]
 

Its value is desired_target[0].

Definition at line 103 of file AddCostToLearner.h.

Referenced by build_(), and makeDeepCopyFromShallowCopy().

real PLearn::AddCostToLearner::to_max
 

Definition at line 121 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().

real PLearn::AddCostToLearner::to_min
 

Definition at line 122 of file AddCostToLearner.h.

Referenced by build_(), and computeCostsFromOutputs().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:27:23 2004 for PLearn by doxygen 1.3.7