#include <MultiInstanceNNet.h>
Inheritance diagram for PLearn::MultiInstanceNNet:
Public Member Functions | |
MultiInstanceNNet () | |
virtual | ~MultiInstanceNNet () |
PLEARN_DECLARE_OBJECT (MultiInstanceNNet) | |
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 | build () |
**** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_() | |
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 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 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 | |
virtual TVec< string > | getTestCostNames () const |
*** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus | |
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 | computeOutput (const Vec &input, Vec &output) const |
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input | |
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 | 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 | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Public Attributes | |
Func | f |
Func | test_costf |
Func | output_and_target_to_cost |
int | max_n_instances |
int | nhidden |
int | nhidden2 |
real | weight_decay |
real | bias_decay |
real | layer1_weight_decay |
real | layer1_bias_decay |
real | layer2_weight_decay |
real | layer2_bias_decay |
real | output_layer_weight_decay |
real | output_layer_bias_decay |
real | direct_in_to_out_weight_decay |
real | classification_regularizer |
bool | L1_penalty |
bool | direct_in_to_out |
real | interval_minval |
real | interval_maxval |
int | test_bag_size |
PP< Optimizer > | optimizer |
int | batch_size |
Protected Member Functions | |
void | initializeParams () |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down) | |
Protected Attributes | |
Var | input |
Var | target |
Var | sampleweight |
Var | w1 |
Var | w2 |
Var | wout |
Var | wdirect |
Var | output |
Var | bag_size |
Var | bag_inputs |
Var | bag_output |
Func | inputs_and_targets_to_test_costs |
Func | inputs_and_targets_to_training_costs |
Func | input_to_logP0 |
Var | nll |
VarArray | costs |
VarArray | penalties |
Var | training_cost |
Var | test_costs |
VarArray | invars |
VarArray | params |
Vec | paramsvalues |
int | optstage_per_lstage |
bool | training_set_has_changed |
Private Types | |
typedef PLearner | inherited |
Private Member Functions | |
void | build_ () |
Private Attributes | |
Vec | instance_logP0 |
Used to store data between calls to computeCostsFromOutput. |
|
Reimplemented from PLearn::PLearner. Definition at line 57 of file MultiInstanceNNet.h. |
|
Definition at line 103 of file MultiInstanceNNet.cc. |
|
Definition at line 124 of file MultiInstanceNNet.cc. |
|
**** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_()
Reimplemented from PLearn::PLearner. Definition at line 185 of file MultiInstanceNNet.cc. References build_(). Referenced by setTrainingSet(), and train(). |
|
|
*** 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. Definition at line 518 of file MultiInstanceNNet.cc. References PLearn::TVec< T >::fill(), instance_logP0, max_n_instances, MISSING_VALUE, nll, PLearn::TVec< T >::resize(), PLearn::safeexp(), PLearn::safeflog(), PLearn::sum(), and test_bag_size. |
|
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input
Implements PLearn::PLearner. Definition at line 484 of file MultiInstanceNNet.cc. References f. |
|
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. Definition at line 492 of file MultiInstanceNNet.cc. References bag_inputs, bag_size, f, PLearn::TVec< T >::fill(), inputs_and_targets_to_test_costs, MISSING_VALUE, sampleweight, target, and test_bag_size. |
|
redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down) ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); } Reimplemented from PLearn::PLearner. Definition at line 128 of file MultiInstanceNNet.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 598 of file MultiInstanceNNet.cc. References initializeParams(). Referenced by setTrainingSet(). |
|
*** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus
Implements PLearn::PLearner. Definition at line 381 of file MultiInstanceNNet.cc. |
|
*** 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 371 of file MultiInstanceNNet.cc. |
|
Definition at line 550 of file MultiInstanceNNet.cc. References direct_in_to_out, PLearn::fill_random_normal(), PLearn::PLearner::inputsize(), PLearn::manual_seed(), nhidden, nhidden2, optimizer, PLearn::seed(), w1, w2, wdirect, and wout. |
|
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. Definition at line 607 of file MultiInstanceNNet.cc. References bag_inputs, bag_output, bag_size, PLearn::CopiesMap, costs, PLearn::deepCopyField(), f, input, input_to_logP0, inputs_and_targets_to_test_costs, inputs_and_targets_to_training_costs, instance_logP0, invars, nll, optimizer, output, output_and_target_to_cost, params, paramsvalues, penalties, sampleweight, target, test_costf, test_costs, training_cost, PLearn::varDeepCopyField(), w1, w2, wdirect, and wout. |
|
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 368 of file MultiInstanceNNet.cc. Referenced by build_(). |
|
|
|
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 191 of file MultiInstanceNNet.cc. References build(), forget(), PLearn::VMat::length(), training_set_has_changed, and PLearn::VMat::width(). |
|
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 391 of file MultiInstanceNNet.cc. References batch_size, build(), PLearn::endl(), f, inputs_and_targets_to_training_costs, PLearn::PP< Function >::isNull(), PLearn::VMat::length(), max_n_instances, optimizer, optstage_per_lstage, params, PLERROR, PLearn::sumOverBags(), PLearn::tostring(), training_set_has_changed, PLearn::ProgressBar::update(), and PLearn::VMat::width(). |
|
Definition at line 74 of file MultiInstanceNNet.h. Referenced by build_(), computeOutputAndCosts(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 75 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 73 of file MultiInstanceNNet.h. Referenced by build_(), computeOutputAndCosts(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 129 of file MultiInstanceNNet.h. Referenced by train(). |
|
Definition at line 111 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 119 of file MultiInstanceNNet.h. |
|
Definition at line 82 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 122 of file MultiInstanceNNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 118 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 95 of file MultiInstanceNNet.h. Referenced by build_(), computeOutput(), computeOutputAndCosts(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 64 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 79 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 77 of file MultiInstanceNNet.h. Referenced by build_(), computeOutputAndCosts(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 78 of file MultiInstanceNNet.h. Referenced by build_(), makeDeepCopyFromShallowCopy(), and train(). |
|
Used to store data between calls to computeCostsFromOutput.
Definition at line 60 of file MultiInstanceNNet.h. Referenced by computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 123 of file MultiInstanceNNet.h. |
|
Definition at line 123 of file MultiInstanceNNet.h. |
|
Definition at line 86 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 121 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 113 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 112 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 115 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 114 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 105 of file MultiInstanceNNet.h. Referenced by build_(), computeCostsFromOutputs(), and train(). |
|
Definition at line 107 of file MultiInstanceNNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 108 of file MultiInstanceNNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 80 of file MultiInstanceNNet.h. Referenced by computeCostsFromOutputs(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 127 of file MultiInstanceNNet.h. Referenced by initializeParams(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 91 of file MultiInstanceNNet.h. Referenced by train(). |
|
Definition at line 72 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 97 of file MultiInstanceNNet.h. Referenced by makeDeepCopyFromShallowCopy(). |
|
Definition at line 117 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 116 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 87 of file MultiInstanceNNet.h. Referenced by build_(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 89 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 83 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 66 of file MultiInstanceNNet.h. Referenced by build_(), computeOutputAndCosts(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 65 of file MultiInstanceNNet.h. Referenced by build_(), computeOutputAndCosts(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 124 of file MultiInstanceNNet.h. Referenced by computeCostsFromOutputs(), and computeOutputAndCosts(). |
|
Definition at line 96 of file MultiInstanceNNet.h. Referenced by makeDeepCopyFromShallowCopy(). |
|
Definition at line 85 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 84 of file MultiInstanceNNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 92 of file MultiInstanceNNet.h. Referenced by setTrainingSet(), and train(). |
|
Definition at line 67 of file MultiInstanceNNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 68 of file MultiInstanceNNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 70 of file MultiInstanceNNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 110 of file MultiInstanceNNet.h. Referenced by build_(). |
|
Definition at line 69 of file MultiInstanceNNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |