PLearn 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::IdentityModule Class Reference

#include <IdentityModule.h>

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

List of all members.

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 OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual IdentityModuledeepCopy (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 PPathdeclaringFile ()

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.

Detailed Description

Definition at line 47 of file IdentityModule.h.


Member Typedef Documentation

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 49 of file IdentityModule.h.


Constructor & Destructor Documentation

PLearn::IdentityModule::IdentityModule ( )

Default constructor.

Definition at line 52 of file IdentityModule.cc.

{}

Member Function Documentation

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.

bool PLearn::IdentityModule::_isa_ ( const Object o) [static]

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:

  • a full matrix : this is the gradient that is provided to the module, and can be used to compute other ports' gradient.
  • an empty matrix: this is a gradient we want to compute and accumulate into. This matrix must have length 0 and a width equal to the width of the corresponding matrix in the 'ports_value' vector (we can thus accumulate gradients using PLearn's ability to keep intact stored values when resizing a matrix' length).
  • a NULL pointer : this is a gradient that is not available, but does not need to be returned (or even computed). The default version tries to use the standard mini-batch bpropUpdate method, when possible.

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;
}

Here is the call graph for this function:

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.

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.
}
void PLearn::IdentityModule::fprop ( const Mat inputs,
Mat outputs 
) [virtual]

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;
}

Here is the call graph for this function:

void PLearn::IdentityModule::fprop ( const Vec input,
Vec output 
) const [virtual]

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;
}

Here is the call graph for this function:

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.


Member Data Documentation

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 162 of file IdentityModule.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines