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

Variable that views another variable, but with a different length() and width() (the only restriction being that length()*width() remain the same) More...

#include <ReshapeVariable.h>

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

List of all members.

Public Member Functions

 ReshapeVariable ()
 Default constructor for persistence.
 ReshapeVariable (Variable *v, int the_length, int the_width)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ReshapeVariabledeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void recomputeSize (int &l, int &w) const
 Recomputes the length l and width w that this variable should have, according to its parent variables.
virtual void fprop ()
 Nothing to do by default.
virtual void bprop ()
 Nothing to do by default.
virtual void symbolicBprop ()
 compute a piece of new Var graph that represents the symbolic derivative of this Var

Static Public Member Functions

static string _classname_ ()
 ReshapeVariable.
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 void declareOptions (OptionList &ol)
 Declare options (data fields) for the class.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.

Protected Attributes

int length_
int width_

Private Types

typedef UnaryVariable inherited

Detailed Description

Variable that views another variable, but with a different length() and width() (the only restriction being that length()*width() remain the same)

* Different views of a mat Var *

Definition at line 55 of file ReshapeVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 57 of file ReshapeVariable.h.


Constructor & Destructor Documentation

PLearn::ReshapeVariable::ReshapeVariable ( ) [inline]

Default constructor for persistence.

Definition at line 64 of file ReshapeVariable.h.

Referenced by symbolicBprop().

{}

Here is the caller graph for this function:

PLearn::ReshapeVariable::ReshapeVariable ( Variable v,
int  the_length,
int  the_width 
)

Definition at line 56 of file ReshapeVariable.cc.

References build_().

    : inherited(v, the_length, the_width), length_(the_length), width_(the_width)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

ReshapeVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

void PLearn::ReshapeVariable::bprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 96 of file ReshapeVariable.cc.

References PLearn::Variable::gradientdata, PLearn::UnaryVariable::input, and PLearn::Variable::nelems().

{
    for(int k=0; k<nelems(); k++)
        input->gradientdata[k] += gradientdata[k];
}

Here is the call graph for this function:

void PLearn::ReshapeVariable::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::UnaryVariable.

Definition at line 63 of file ReshapeVariable.cc.

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

Here is the call graph for this function:

void PLearn::ReshapeVariable::build_ ( ) [protected]

Object-specific post-constructor.

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that its parent's build_() has already been called.

Reimplemented from PLearn::UnaryVariable.

Definition at line 70 of file ReshapeVariable.cc.

References PLearn::UnaryVariable::input, PLearn::Var::length(), PLearn::Variable::length(), PLERROR, PLearn::Var::width(), and PLearn::Variable::width().

Referenced by build(), and ReshapeVariable().

{
    if (input) {
        if(length() * width() != input.length() * input.width())
            PLERROR("In ReshapeVariable: length()*width() is different from the original var's length()*width()");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

void PLearn::ReshapeVariable::declareOptions ( OptionList ol) [static]

Declare options (data fields) for the class.

Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).

  static void MyDerivedClass::declareOptions(OptionList& ol)
  {
      declareOption(ol, "inputsize", &MyObject::inputsize_,
                    OptionBase::buildoption,
                    "The size of the input; it must be provided");
      declareOption(ol, "weights", &MyObject::weights,
                    OptionBase::learntoption,
                    "The learned model weights");
      inherited::declareOptions(ol);
  }
Parameters:
olList of options that is progressively being constructed for the current class.

Reimplemented from PLearn::UnaryVariable.

Definition at line 79 of file ReshapeVariable.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), length_, and width_.

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 67 of file ReshapeVariable.h.

:
    void build_();
ReshapeVariable * PLearn::ReshapeVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

void PLearn::ReshapeVariable::fprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 89 of file ReshapeVariable.cc.

References PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.

{
    for(int k=0; k<nelems(); k++)
        valuedata[k] = input->valuedata[k];
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file ReshapeVariable.cc.

void PLearn::ReshapeVariable::recomputeSize ( int l,
int w 
) const [virtual]

Recomputes the length l and width w that this variable should have, according to its parent variables.

This is used for ex. by sizeprop() The default version stupidly returns the current dimensions, so make sure to overload it in subclasses if this is not appropriate.

Reimplemented from PLearn::Variable.

Definition at line 86 of file ReshapeVariable.cc.

References length_, and width_.

{ l=length_; w=width_; }
void PLearn::ReshapeVariable::symbolicBprop ( ) [virtual]

compute a piece of new Var graph that represents the symbolic derivative of this Var

Reimplemented from PLearn::Variable.

Definition at line 103 of file ReshapeVariable.cc.

References PLearn::Variable::g, PLearn::UnaryVariable::input, PLearn::Var::length(), ReshapeVariable(), and PLearn::Var::width().

{
    input->accg(new ReshapeVariable(g,input->length(),input->width()));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 67 of file ReshapeVariable.h.

Definition at line 60 of file ReshapeVariable.h.

Referenced by declareOptions(), and recomputeSize().

Definition at line 60 of file ReshapeVariable.h.

Referenced by declareOptions(), and recomputeSize().


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