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

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <NullModule.h>

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

List of all members.

Public Member Functions

 NullModule (const string &name="", bool call_build_=true)
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
virtual void fprop (const Vec &input, Vec &output) const
 given the input, compute the output (possibly resize it appropriately)
virtual void forget ()
 Reset the parameters to the state they would be BEFORE starting training.
virtual void fprop (const TVec< Mat * > &ports_value)
 Does nothing.
virtual void bpropAccUpdate (const TVec< Mat * > &ports_value, const TVec< Mat * > &ports_gradient)
 If required, the gradient w.r.t. the port is 0.
virtual const TVec< string > & getPorts ()
 One single port: 'null'.
virtual const TMat< int > & getPortSizes ()
 The port size is undefined.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual NullModuledeepCopy (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

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

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 57 of file NullModule.h.


Member Typedef Documentation

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 59 of file NullModule.h.


Constructor & Destructor Documentation

PLearn::NullModule::NullModule ( const string &  name = "",
bool  call_build_ = true 
)

### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!

Constructor.

Definition at line 59 of file NullModule.cc.

References build_().

                                                          :
    inherited(name.empty() ? classname() : name, call_build_)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

string PLearn::NullModule::_classname_ ( ) [static]

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 54 of file NullModule.cc.

OptionList & PLearn::NullModule::_getOptionList_ ( ) [static]

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 54 of file NullModule.cc.

RemoteMethodMap & PLearn::NullModule::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 54 of file NullModule.cc.

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

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 54 of file NullModule.cc.

Object * PLearn::NullModule::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 54 of file NullModule.cc.

StaticInitializer NullModule::_static_initializer_ & PLearn::NullModule::_static_initialize_ ( ) [static]

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 54 of file NullModule.cc.

void PLearn::NullModule::bpropAccUpdate ( const TVec< Mat * > &  ports_value,
const TVec< Mat * > &  ports_gradient 
) [virtual]

If required, the gradient w.r.t. the port is 0.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 136 of file NullModule.cc.

References PLearn::TVec< T >::length(), PLearn::OnlineLearningModule::nPorts(), and PLASSERT.

{
    PLASSERT( ports_gradient.length() == nPorts() );
    Mat* null_grad = ports_gradient[0];
    if (null_grad) {
        // Noone should ever provide us with a gradient w.r.t. 'null'.
        PLASSERT( null_grad->isEmpty() );
        // All we need to do is resize the gradient matrix.
        PLASSERT( ports_value[0] );
        PLASSERT( null_grad->width() == ports_value[0]->width() );
        null_grad->resize(ports_value[0]->length(), null_grad->width());
    }
}

Here is the call graph for this function:

void PLearn::NullModule::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 103 of file NullModule.cc.

References PLearn::OnlineLearningModule::build(), and build_().

Here is the call graph for this function:

void PLearn::NullModule::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 86 of file NullModule.cc.

Referenced by build(), and NullModule().

{
    // ### 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.
}

Here is the caller graph for this function:

string PLearn::NullModule::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 54 of file NullModule.cc.

void PLearn::NullModule::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 66 of file NullModule.cc.

References PLearn::OnlineLearningModule::declareOptions().

{
    // ### 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)

    // ### ex:
    // declareOption(ol, "myoption", &NullModule::myoption,
    //               OptionBase::buildoption,
    //               "Help text describing this option");
    // ...

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

static const PPath& PLearn::NullModule::declaringFile ( ) [inline, static]

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 179 of file NullModule.h.

:
    //#####  Protected Member Functions  ######################################
NullModule * PLearn::NullModule::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 54 of file NullModule.cc.

void PLearn::NullModule::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 217 of file NullModule.cc.

{
}
void PLearn::NullModule::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 120 of file NullModule.cc.

{
    // Nothing to do.
}
void PLearn::NullModule::fprop ( const TVec< Mat * > &  ports_value) [virtual]

Does nothing.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 125 of file NullModule.cc.

References PLearn::TVec< T >::length(), PLearn::OnlineLearningModule::nPorts(), and PLASSERT.

{
    // Nothing to do.
    PLASSERT( ports_value.length() == nPorts() );
    // Ensure we are not asking for the value of the 'null' port.
    PLASSERT( !ports_value[0] || !ports_value[0]->isEmpty() );
}

Here is the call graph for this function:

OptionList & PLearn::NullModule::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 54 of file NullModule.cc.

OptionMap & PLearn::NullModule::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 54 of file NullModule.cc.

const TVec< string > & PLearn::NullModule::getPorts ( ) [virtual]

One single port: 'null'.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 154 of file NullModule.cc.

References PLearn::TVec< T >::append(), and PLearn::TVec< T >::isEmpty().

                                         {
    static TVec<string> null_port;
    if (null_port.isEmpty())
        null_port.append("null");
    return null_port;
}

Here is the call graph for this function:

const TMat< int > & PLearn::NullModule::getPortSizes ( ) [virtual]

The port size is undefined.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 164 of file NullModule.cc.

References PLearn::TMat< T >::fill(), PLearn::TMat< T >::isEmpty(), and PLearn::TMat< T >::resize().

                                          {
    static TMat<int> null_size;
    if (null_size.isEmpty()) {
        null_size.resize(1, 2);
        null_size.fill(-1);
    }
    return null_size;
}

Here is the call graph for this function:

RemoteMethodMap & PLearn::NullModule::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 54 of file NullModule.cc.

void PLearn::NullModule::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 112 of file NullModule.cc.

References PLearn::OnlineLearningModule::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::OnlineLearningModule.

Definition at line 179 of file NullModule.h.


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