#include <NNet.h>
Inheritance diagram for PLearn::NNet:
Public Types | |
typedef PLearner | inherited |
Public Member Functions | |
NNet () | |
virtual | ~NNet () |
PLEARN_DECLARE_OBJECT (NNet) | |
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 | nhidden |
int | nhidden2 |
int | noutputs |
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 |
real | margin |
bool | fixed_output_weights |
int | rbf_layer_size |
bool | first_class_is_junk |
bool | L1_penalty |
real | input_reconstruction_penalty |
bool | direct_in_to_out |
string | output_transfer_func |
string | hidden_transfer_func |
real | interval_minval |
real | interval_maxval |
Array< string > | cost_funcs |
a list of cost functions to use in the form "[ cf1; cf2; cf3; ... ]" | |
PP< Optimizer > | optimizer |
int | batch_size |
string | initialization_method |
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 | outbias |
Var | wdirect |
Var | wrec |
Var | rbf_centers |
Var | rbf_sigmas |
Var | junk_prob |
Var | output |
Var | predicted_input |
VarArray | costs |
VarArray | penalties |
Var | training_cost |
Var | test_costs |
VarArray | invars |
VarArray | params |
Vec | paramsvalues |
Private Member Functions | |
void | build_ () |
|
Reimplemented from PLearn::PLearner. |
|
Definition at line 83 of file NNet.cc. References PLearn::tanh(). |
|
|
|
**** SUBCLASS WRITING: **** This method should be redefined in subclasses, to just call inherited::build() and then build_()
Reimplemented from PLearn::PLearner. Definition at line 242 of file NNet.cc. References build_(). Referenced by 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 661 of file NNet.cc. References output_and_target_to_cost. |
|
*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the output from the input
Implements PLearn::PLearner. Definition at line 649 of file NNet.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 654 of file NNet.cc. References test_costf. |
|
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 116 of file NNet.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 744 of file NNet.cc. References initializeParams(). |
|
*** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus
Implements PLearn::PLearner. Definition at line 579 of file NNet.cc. References cost_funcs. |
|
*** 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 574 of file NNet.cc. References cost_funcs. |
|
Definition at line 667 of file NNet.cc. References direct_in_to_out, PLearn::fill_random_discrete(), PLearn::fill_random_uniform(), fixed_output_weights, initialization_method, PLearn::PLearner::inputsize(), PLearn::manual_seed(), nhidden, nhidden2, optimizer, PLERROR, PLearn::TVec< T >::resize(), PLearn::seed(), PLearn::TVec< T >::size(), PLearn::sqrt(), 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 753 of file NNet.cc. References PLearn::CopiesMap, costs, PLearn::deepCopyField(), f, input, invars, junk_prob, optimizer, outbias, output, output_and_target_to_cost, params, paramsvalues, penalties, predicted_input, rbf_centers, rbf_sigmas, sampleweight, target, test_costf, test_costs, training_cost, PLearn::varDeepCopyField(), w1, w2, wdirect, wout, and wrec. |
|
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 571 of file NNet.cc. References noutputs. Referenced by build_(). |
|
|
|
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 585 of file NNet.cc. References batch_size, build(), PLearn::endl(), f, invars, PLearn::PP< Function >::isNull(), PLearn::VMat::length(), PLearn::meanOf(), optimizer, output_and_target_to_cost, params, PLERROR, test_costf, PLearn::tostring(), training_cost, and PLearn::ProgressBar::update(). |
|
Definition at line 127 of file NNet.h. Referenced by train(). |
|
Definition at line 97 of file NNet.h. Referenced by build_(). |
|
Definition at line 105 of file NNet.h. Referenced by build_(). |
|
a list of cost functions to use in the form "[ cf1; cf2; cf3; ... ]"
Definition at line 122 of file NNet.h. Referenced by build_(), getTestCostNames(), and getTrainCostNames(). |
|
Definition at line 70 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 114 of file NNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 104 of file NNet.h. Referenced by build_(). |
|
Definition at line 80 of file NNet.h. Referenced by build_(), computeOutput(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 110 of file NNet.h. Referenced by build_(). |
|
Definition at line 107 of file NNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 116 of file NNet.h. Referenced by build_(). |
|
Definition at line 130 of file NNet.h. Referenced by initializeParams(). |
|
Definition at line 56 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 113 of file NNet.h. Referenced by build_(). |
|
Definition at line 117 of file NNet.h. Referenced by build_(). |
|
Definition at line 117 of file NNet.h. Referenced by build_(). |
|
Definition at line 74 of file NNet.h. Referenced by build_(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 67 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 112 of file NNet.h. Referenced by build_(). |
|
Definition at line 99 of file NNet.h. Referenced by build_(). |
|
Definition at line 98 of file NNet.h. Referenced by build_(). |
|
Definition at line 101 of file NNet.h. Referenced by build_(). |
|
Definition at line 100 of file NNet.h. Referenced by build_(). |
|
Definition at line 106 of file NNet.h. Referenced by build_(). |
|
Definition at line 92 of file NNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 93 of file NNet.h. Referenced by build_(), and initializeParams(). |
|
Definition at line 94 of file NNet.h. Referenced by outputsize(). |
|
Definition at line 125 of file NNet.h. Referenced by initializeParams(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 62 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 68 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 82 of file NNet.h. Referenced by build_(), computeCostsFromOutputs(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 103 of file NNet.h. Referenced by build_(). |
|
Definition at line 102 of file NNet.h. Referenced by build_(). |
|
Definition at line 115 of file NNet.h. Referenced by build_(). |
|
Definition at line 75 of file NNet.h. Referenced by build_(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 77 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 71 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 69 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 65 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 109 of file NNet.h. Referenced by build_(). |
|
Definition at line 66 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 58 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 57 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 81 of file NNet.h. Referenced by build_(), computeOutputAndCosts(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 73 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 72 of file NNet.h. Referenced by build_(), makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 59 of file NNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 60 of file NNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 63 of file NNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 96 of file NNet.h. Referenced by build_(). |
|
Definition at line 61 of file NNet.h. Referenced by build_(), initializeParams(), and makeDeepCopyFromShallowCopy(). |
|
Definition at line 64 of file NNet.h. Referenced by build_(), and makeDeepCopyFromShallowCopy(). |