PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <SurfaceTemplateLearner.h>
Public Member Functions | |
SurfaceTemplateLearner () | |
Default constructor. | |
virtual void | train () |
(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 | setTrainingSet (VMat training_set, bool call_forget=true) |
Computes the output from the input. | |
virtual void | test (VMat testset, PP< VecStatsCollector > test_stats, VMat testoutputs=0, VMat testcosts=0) const |
Overridden in order to properly obtain the fieldnames. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SurfaceTemplateLearner * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Finish building the object; just call inherited::build followed by build_() | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
real | min_feature_dev |
real | min_geom_dev |
bool | simple_mixture |
VMat | templates_source |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef NNet | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 58 of file SurfaceTemplateLearner.h.
typedef NNet PLearn::SurfaceTemplateLearner::inherited [private] |
Reimplemented from PLearn::NNet.
Definition at line 60 of file SurfaceTemplateLearner.h.
PLearn::SurfaceTemplateLearner::SurfaceTemplateLearner | ( | ) |
Default constructor.
Definition at line 55 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::cost_funcs, PLearn::NNet::n_non_params_in_first_hidden_layer, PLearn::NNet::nhidden, PLearn::NNet::nhidden2, PLearn::NNet::noutputs, PLearn::NNet::output_transfer_func, and PLearn::NNet::transpose_first_hidden_layer.
: min_feature_dev(1e-3), min_geom_dev(1e-3), simple_mixture(false) { nhidden2 = 10; // Set some NNet options whose value is fixed in this learner. nhidden = 0; noutputs = 1; output_transfer_func = "sigmoid"; cost_funcs = TVec<string>(1, "stable_cross_entropy"); transpose_first_hidden_layer = false; n_non_params_in_first_hidden_layer = 1; }
string PLearn::SurfaceTemplateLearner::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
OptionList & PLearn::SurfaceTemplateLearner::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
RemoteMethodMap & PLearn::SurfaceTemplateLearner::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
Object * PLearn::SurfaceTemplateLearner::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
StaticInitializer SurfaceTemplateLearner::_static_initializer_ & PLearn::SurfaceTemplateLearner::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
void PLearn::SurfaceTemplateLearner::build | ( | ) | [virtual] |
Finish building the object; just call inherited::build followed by build_()
Reimplemented from PLearn::NNet.
Definition at line 280 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::build(), build_(), PLearn::NNet::first_hidden_layer_is_output, PLearn::NNet::output_transfer_func, simple_mixture, templates_source, and PLearn::PLearner::train_set.
{ // Very ugly hack: because NNet::build_() will perform a fprop(), we need a // sensible input value for this fprop, which means we need a training set. // A simple way to fix this would be to remove the // output_and_target_to_cost->recomputeParents() in the NNet build, but one // should make sure it does not break anything first. if (!train_set && templates_source) this->train_set = templates_source; // Because the overall network is built in the NNet build, the simple // mixture case must be handled before calling it. first_hidden_layer_is_output = simple_mixture; // Since we are already hacking this method, we may continue doing so: // depending on the value of 'simple_mixture' (true or false), the output // transfer function should be either nothing or a sigmoid. output_transfer_func = simple_mixture ? "none" : "sigmoid"; inherited::build(); build_(); }
void PLearn::SurfaceTemplateLearner::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::NNet.
Definition at line 252 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::first_hidden_layer, i, PLearn::TVec< T >::length(), min_feature_dev, min_geom_dev, PLERROR, and simple_mixture.
Referenced by build().
{ // Ensure the first hidden layer is a subclass of ScoreLayerVariable. if (first_hidden_layer) { PP<ScoreLayerVariable> score_layer = (ScoreLayerVariable*) ((Variable*) first_hidden_layer); if (!score_layer) PLERROR("In SurfaceTemplateLearner::build_ - The first hidden " "layer, as given by the 'score_layer' option, must be a " "subclass of ScoreLayerVariable"); // Set the minimum value for template standard deviations. if (score_layer->run_icp_var) { TVec< PP<ChemicalICP> > icp_aligners = score_layer->run_icp_var->icp_aligners; for (int i = 0; i < icp_aligners.length(); i++) { icp_aligners[i]->all_template_feat_dev-> setMinValue(min_feature_dev); icp_aligners[i]->template_geom_dev->setMinValue(min_geom_dev); } } // Set value of 'simple_mixture' option. score_layer->simple_mixture = this->simple_mixture; } }
string PLearn::SurfaceTemplateLearner::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
void PLearn::SurfaceTemplateLearner::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::NNet.
Definition at line 73 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::bias_decay, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::NNet::declareOptions(), PLearn::NNet::direct_in_to_out, PLearn::NNet::direct_in_to_out_weight_decay, PLearn::NNet::do_not_change_params, PLearn::NNet::first_class_is_junk, PLearn::NNet::first_hidden_layer, PLearn::NNet::fixed_output_weights, PLearn::PLearner::forget_when_training_set_changes, PLearn::NNet::hidden_transfer_func, PLearn::NNet::initialization_method, PLearn::NNet::input_reconstruction_penalty, PLearn::NNet::L1_penalty, PLearn::NNet::layer1_bias_decay, PLearn::NNet::layer1_weight_decay, PLearn::NNet::layer2_bias_decay, PLearn::NNet::layer2_weight_decay, PLearn::NNet::margin, min_feature_dev, min_geom_dev, PLearn::NNet::n_non_params_in_first_hidden_layer, PLearn::NNet::nhidden2, PLearn::OptionBase::nosave, PLearn::NNet::noutputs, PLearn::PLearner::nservers, PLearn::NNet::output_layer_bias_decay, PLearn::NNet::output_layer_weight_decay, PLearn::NNet::output_transfer_func, PLearn::NNet::rbf_layer_size, PLearn::redeclareOption(), PLearn::PLearner::save_trainingset_prefix, simple_mixture, templates_source, and PLearn::NNet::transpose_first_hidden_layer.
{ declareOption(ol, "min_feature_dev", &SurfaceTemplateLearner::min_feature_dev, OptionBase::buildoption, "Minimum feature standard deviations allowed."); declareOption(ol, "min_geom_dev", &SurfaceTemplateLearner::min_geom_dev, OptionBase::buildoption, "Minimum geometric standard deviations allowed."); // We rename 'first_hidden_layer' into 'score_layer' to avoid potential // confusion. declareOption(ol, "score_layer", &SurfaceTemplateLearner::first_hidden_layer, OptionBase::buildoption, "The layer of scores (should be a ScoreLayerVariable)."); declareOption(ol, "simple_mixture", &SurfaceTemplateLearner::simple_mixture, OptionBase::buildoption, "If true, then instead of building another hidden layer on top of\n" "alignment scores, we use them directly in a mixture of Gaussians\n" "fashion to estimate the probability of being active."); declareOption(ol, "templates_source", &SurfaceTemplateLearner::templates_source, OptionBase::buildoption, "The dataset where templates are taken from. If not provided, the\n" "training set will be used instead."); // Now call the parent class' declareOptions inherited::declareOptions(ol); // Redeclare parent's option to make this learner more user-friendly. // 'nhidden' now modifies the 'nhidden2' parameter in NNet, since a // SurfaceTemplateLearner has always a first hidden layer that is a // ScoreLayerVariable. redeclareOption(ol, "nhidden", &SurfaceTemplateLearner::nhidden2, OptionBase::buildoption, "Number of hidden units."); redeclareOption(ol, "nhidden2", &SurfaceTemplateLearner::nhidden2, OptionBase::nosave, "Not used (see nhidden)."); redeclareOption(ol, "noutputs", &SurfaceTemplateLearner::noutputs, OptionBase::nosave, "Not used (= 1)."); redeclareOption(ol, "bias_decay", &SurfaceTemplateLearner::bias_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "layer1_weight_decay", &SurfaceTemplateLearner::layer1_weight_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "layer1_bias_decay", &SurfaceTemplateLearner::layer1_bias_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "layer2_weight_decay", &SurfaceTemplateLearner::layer2_weight_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "layer2_bias_decay", &SurfaceTemplateLearner::layer2_bias_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "output_layer_weight_decay", &SurfaceTemplateLearner::output_layer_weight_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "output_layer_bias_decay", &SurfaceTemplateLearner::output_layer_bias_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "direct_in_to_out_weight_decay", &SurfaceTemplateLearner::direct_in_to_out_weight_decay, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "L1_penalty", &SurfaceTemplateLearner::L1_penalty, OptionBase::nosave, "Not used (deprecated)."); redeclareOption(ol, "fixed_output_weights", &SurfaceTemplateLearner::fixed_output_weights, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "input_reconstruction_penalty", &SurfaceTemplateLearner::input_reconstruction_penalty, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "direct_in_to_out", &SurfaceTemplateLearner::direct_in_to_out, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "rbf_layer_size", &SurfaceTemplateLearner::rbf_layer_size, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "first_class_is_junk", &SurfaceTemplateLearner::first_class_is_junk, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "output_transfer_func", &SurfaceTemplateLearner::output_transfer_func, OptionBase::nosave, "Not used (= sigmoid or none, depending on 'simple_mixture')."); redeclareOption(ol, "hidden_transfer_func", &SurfaceTemplateLearner::hidden_transfer_func, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "first_hidden_layer", &SurfaceTemplateLearner::first_hidden_layer, OptionBase::nosave, "Not used (renamed to 'score_layer')."); redeclareOption(ol, "transpose_first_hidden_layer", &SurfaceTemplateLearner::transpose_first_hidden_layer, OptionBase::nosave, "Not used (= false)."); redeclareOption(ol, "n_non_params_in_first_hidden_layer", &SurfaceTemplateLearner::n_non_params_in_first_hidden_layer, OptionBase::nosave, "Not used (= 1 because of the 'final_output' variable in the\n" "ScoreLayerVariable)."); redeclareOption(ol, "margin", &SurfaceTemplateLearner::margin, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "do_not_change_params", &SurfaceTemplateLearner::do_not_change_params, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "initialization_method", &SurfaceTemplateLearner::initialization_method, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "forget_when_training_set_changes", &SurfaceTemplateLearner::forget_when_training_set_changes, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "nservers", &SurfaceTemplateLearner::nservers, OptionBase::nosave, "Not used (simplification)."); redeclareOption(ol, "save_trainingset_prefix", &SurfaceTemplateLearner::save_trainingset_prefix, OptionBase::nosave, "Not used (simplification)."); }
static const PPath& PLearn::SurfaceTemplateLearner::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::NNet.
Definition at line 121 of file SurfaceTemplateLearner.h.
:
//##### Protected Member Functions ######################################
SurfaceTemplateLearner * PLearn::SurfaceTemplateLearner::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
OptionList & PLearn::SurfaceTemplateLearner::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
OptionMap & PLearn::SurfaceTemplateLearner::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
RemoteMethodMap & PLearn::SurfaceTemplateLearner::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::NNet.
Definition at line 50 of file SurfaceTemplateLearner.cc.
void PLearn::SurfaceTemplateLearner::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::NNet.
Definition at line 306 of file SurfaceTemplateLearner.cc.
References PLearn::deepCopyField(), PLearn::NNet::makeDeepCopyFromShallowCopy(), and templates_source.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); deepCopyField(templates_source, copies); // ### Remove this line when you have fully implemented this method. // PLERROR("SurfaceTemplateLearner::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::SurfaceTemplateLearner::setTrainingSet | ( | VMat | training_set, |
bool | call_forget = true |
||
) | [virtual] |
Computes the output from the input.
Computes the costs from already computed output. Overridden in order to properly obtain the fieldnames.
Reimplemented from PLearn::NNet.
Definition at line 324 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::first_hidden_layer, PLearn::NNet::setTrainingSet(), and templates_source.
{ // Rebuild the internal score layer. PP<ScoreLayerVariable> score_layer = (ScoreLayerVariable*) ((Variable*) first_hidden_layer); score_layer->templates_source = this->templates_source ? this->templates_source : training_set; score_layer->setMappingsSource(training_set); score_layer->build(); inherited::setTrainingSet(training_set, call_forget); }
void PLearn::SurfaceTemplateLearner::test | ( | VMat | testset, |
PP< VecStatsCollector > | test_stats, | ||
VMat | testoutputs = 0 , |
||
VMat | testcosts = 0 |
||
) | const [virtual] |
Overridden in order to properly obtain the fieldnames.
Reimplemented from PLearn::PLearner.
Definition at line 341 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::first_hidden_layer, and PLearn::PLearner::test().
{ PP<ScoreLayerVariable> score_layer = (ScoreLayerVariable*) ((Variable*) first_hidden_layer); score_layer->setMappingsSource(testset); inherited::test(testset, test_stats, testoutputs, testcosts); }
void PLearn::SurfaceTemplateLearner::train | ( | ) | [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!).
Overridden to ensure the mappings source in the score layer is properly set.
Reimplemented from PLearn::NNet.
Definition at line 361 of file SurfaceTemplateLearner.cc.
References PLearn::NNet::first_hidden_layer, i, PLearn::TVec< T >::length(), PLearn::PLearner::stage, PLearn::NNet::train(), and PLearn::PLearner::train_set.
{ PP<ScoreLayerVariable> score_layer = (ScoreLayerVariable*) ((Variable*) first_hidden_layer); score_layer->setMappingsSource(train_set); if (stage == 0) { // Make sure all ICP aligners forget any previously computed alignment. // This can be important when they use some memory scheme, since at // build time a first alignment might be performed, and should probably // be forgotten. TVec< PP<ChemicalICP> > icps = score_layer->run_icp_var->icp_aligners; for (int i = 0; i < icps.length(); i++) icps[i]->forgetMemorizedAlignments(); } inherited::train(); }
Reimplemented from PLearn::NNet.
Definition at line 121 of file SurfaceTemplateLearner.h.
Definition at line 65 of file SurfaceTemplateLearner.h.
Referenced by build_(), and declareOptions().
Definition at line 66 of file SurfaceTemplateLearner.h.
Referenced by build_(), and declareOptions().
Definition at line 68 of file SurfaceTemplateLearner.h.
Referenced by build(), build_(), and declareOptions().
Definition at line 70 of file SurfaceTemplateLearner.h.
Referenced by build(), declareOptions(), makeDeepCopyFromShallowCopy(), and setTrainingSet().