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

A subsample var; equals subrample(input, the_subsamplefactor) More...

#include <SubsampleVariable.h>

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

List of all members.

Public Member Functions

 SubsampleVariable ()
 Default constructor for persistence.
 SubsampleVariable (Variable *input, int the_subsamplefactor)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SubsampleVariabledeepCopy (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_ ()
 SubsampleVariable.
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 subsamplefactor

Private Types

typedef UnaryVariable inherited

Detailed Description

A subsample var; equals subrample(input, the_subsamplefactor)

Definition at line 53 of file SubsampleVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SubsampleVariable.h.


Constructor & Destructor Documentation

PLearn::SubsampleVariable::SubsampleVariable ( ) [inline]

Default constructor for persistence.

Definition at line 62 of file SubsampleVariable.h.

PLearn::SubsampleVariable::SubsampleVariable ( Variable input,
int  the_subsamplefactor 
)

Definition at line 55 of file SubsampleVariable.cc.

References build_().

    : inherited(input, input->length()/the_subsamplefactor, input->width()/the_subsamplefactor), 
      subsamplefactor(the_subsamplefactor) 
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

SubsampleVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 100 of file SubsampleVariable.cc.

References c, i, PLearn::UnaryVariable::input, j, PLearn::Variable::length(), PLearn::Variable::matGradient, PLearn::norm(), subsamplefactor, and PLearn::Variable::width().

{
    int norm = subsamplefactor * subsamplefactor;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++)
        {
            real* inputgradientptr = input->matGradient[subsamplefactor*i]+subsamplefactor*j;
            real thisgradient = matGradient(i,j);
            for(int l=0; l<subsamplefactor; l++, inputgradientptr += input->matGradient.mod())
                for(int c=0; c<subsamplefactor; c++)
                {
                    inputgradientptr[c] = thisgradient/norm;
                }
        }
}

Here is the call graph for this function:

void PLearn::SubsampleVariable::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 SubsampleVariable.cc.

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

Here is the call graph for this function:

void PLearn::SubsampleVariable::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 SubsampleVariable.cc.

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

Referenced by build(), and SubsampleVariable().

{
    if (input) {
        if (input->length() % subsamplefactor != 0 || input->width() % subsamplefactor != 0)
            PLERROR("In SubsampleVariable constructor: Dimensions of input are not dividable by subsamplefactor");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

void PLearn::SubsampleVariable::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 SubsampleVariable.cc.

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 65 of file SubsampleVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 94 of file SubsampleVariable.cc.

References PLearn::UnaryVariable::input, PLearn::Variable::matValue, PLearn::subsample(), and subsamplefactor.

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 53 of file SubsampleVariable.cc.

void PLearn::SubsampleVariable::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 85 of file SubsampleVariable.cc.

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

{
    if (input) {
        l = input->length() / subsamplefactor;
        w = input->width()/subsamplefactor;
    } else
        l = w = 0;
}

Here is the call graph for this function:

void PLearn::SubsampleVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 117 of file SubsampleVariable.cc.

References PLERROR.

{ PLERROR("SubsampleVariable::symbolicBprop() not yet implemented"); }

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 65 of file SubsampleVariable.h.

Definition at line 58 of file SubsampleVariable.h.

Referenced by bprop(), build_(), declareOptions(), fprop(), and recomputeSize().


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