PLearn 0.1
|
#include <IdentityModule.h>
Public Member Functions | |
IdentityModule () | |
Default constructor. | |
virtual void | fprop (const Vec &input, Vec &output) const |
given the input, compute the output (possibly resize it appropriately) | |
virtual void | fprop (const Mat &inputs, Mat &outputs) |
Mini-batch fprop. | |
virtual void | bpropAccUpdate (const TVec< Mat * > &ports_value, const TVec< Mat * > &ports_gradient) |
Perform a back propagation step (also updating parameters according to the provided gradient). | |
virtual void | forget () |
Reset the parameters to the state they would be BEFORE starting training. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual IdentityModule * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
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 () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef OnlineLearningModule | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 47 of file IdentityModule.h.
typedef OnlineLearningModule PLearn::IdentityModule::inherited [private] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 49 of file IdentityModule.h.
PLearn::IdentityModule::IdentityModule | ( | ) |
string PLearn::IdentityModule::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 50 of file IdentityModule.cc.
OptionList & PLearn::IdentityModule::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 50 of file IdentityModule.cc.
RemoteMethodMap & PLearn::IdentityModule::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 50 of file IdentityModule.cc.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 50 of file IdentityModule.cc.
Object * PLearn::IdentityModule::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 50 of file IdentityModule.cc.
StaticInitializer IdentityModule::_static_initializer_ & PLearn::IdentityModule::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 50 of file IdentityModule.cc.
void PLearn::IdentityModule::bpropAccUpdate | ( | const TVec< Mat * > & | ports_value, |
const TVec< Mat * > & | ports_gradient | ||
) | [virtual] |
Perform a back propagation step (also updating parameters according to the provided gradient).
The matrices in 'ports_value' must be the same as the ones given in a previous call to 'fprop' (and thus they should in particular contain the result of the fprop computation). However, they are not necessarily the same as the ones given in the LAST call to 'fprop': if there is a need to store an internal module state, this should be done using a specific port to store this state. Each Mat* pointer in the 'ports_gradient' vector can be one of:
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 122 of file IdentityModule.cc.
References PLearn::TMat< T >::isEmpty(), PLearn::TMat< T >::length(), PLearn::TVec< T >::length(), PLASSERT, and PLearn::TMat< T >::width().
{ // Deal with 'standard case' only. PLASSERT( ports_gradient.length() == 2 ); Mat* input_grad = ports_gradient[0]; Mat* output_grad = ports_gradient[1]; if (!input_grad) return; PLASSERT( output_grad && !output_grad->isEmpty() && input_grad->isEmpty() ); PLASSERT( input_grad->width() == output_grad->width() ); input_grad->resize(output_grad->length(), input_grad->width()); *input_grad += *output_grad; }
void PLearn::IdentityModule::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 90 of file IdentityModule.cc.
{ inherited::build(); build_(); }
void PLearn::IdentityModule::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 75 of file IdentityModule.cc.
{ // ### This method should do the real building of the object, // ### according to set 'options', in *any* situation. // ### Typical situations include: // ### - Initial building of an object from a few user-specified options // ### - Building of a "reloaded" object: i.e. from the complete set of // ### all serialised options. // ### - Updating or "re-building" of an object after a few "tuning" // ### options have been modified. // ### You should assume that the parent class' build_() has already been // ### called. }
string PLearn::IdentityModule::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file IdentityModule.cc.
void PLearn::IdentityModule::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 58 of file IdentityModule.cc.
{ // ### Declare all of this object's options here. // ### For the "flags" of each option, you should typically specify // ### one of OptionBase::buildoption, OptionBase::learntoption or // ### OptionBase::tuningoption. If you don't provide one of these three, // ### this option will be ignored when loading values from a script. // ### You can also combine flags, for example with OptionBase::nosave: // ### (OptionBase::buildoption | OptionBase::nosave) // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::IdentityModule::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 162 of file IdentityModule.h.
:
//##### Protected Member Functions ######################################
IdentityModule * PLearn::IdentityModule::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 50 of file IdentityModule.cc.
void PLearn::IdentityModule::forget | ( | ) | [virtual] |
Reset the parameters to the state they would be BEFORE starting training.
Note that this method is necessarily called from build().
Implements PLearn::OnlineLearningModule.
Definition at line 182 of file IdentityModule.cc.
{
// Nothing to forget.
}
Mini-batch fprop.
Default implementation raises an error.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 114 of file IdentityModule.cc.
References PLearn::TMat< T >::length(), PLearn::TMat< T >::resize(), and PLearn::TMat< T >::width().
{ outputs.resize(inputs.length(), inputs.width()); outputs << inputs; }
given the input, compute the output (possibly resize it appropriately)
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 108 of file IdentityModule.cc.
References PLearn::TVec< T >::length(), and PLearn::TVec< T >::resize().
{ output.resize(input.length()); output << input; }
OptionList & PLearn::IdentityModule::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file IdentityModule.cc.
OptionMap & PLearn::IdentityModule::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file IdentityModule.cc.
RemoteMethodMap & PLearn::IdentityModule::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 50 of file IdentityModule.cc.
void PLearn::IdentityModule::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 100 of file IdentityModule.cc.
{ inherited::makeDeepCopyFromShallowCopy(copies); }
Reimplemented from PLearn::OnlineLearningModule.
Definition at line 162 of file IdentityModule.h.