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

#include <RowAtPositionVariable.h>

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

List of all members.

Public Member Functions

 RowAtPositionVariable ()
 Default constructor for persistence.
 RowAtPositionVariable (Variable *input1, Variable *input2, int the_length)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RowAtPositionVariabledeepCopy (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 ()
 compute output given input
virtual void bprop ()
virtual void symbolicBprop ()
 compute a piece of new Var graph that represents the symbolic derivative of this Var
virtual void rfprop ()

Static Public Member Functions

static string _classname_ ()
 RowAtPositionVariable.
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_ ()
 This does the actual building.

Protected Attributes

int length_

Private Types

typedef BinaryVariable inherited

Detailed Description

* Variables positionned inside a larger zero variable ... *

A variable of length() 'length()', and of width() input1->nelems(), filled with zeros except for the row indexed by input2, which is a copy of input1 (this is used in particular for the symbolic bprop of VarRowVariable)

Definition at line 59 of file RowAtPositionVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 61 of file RowAtPositionVariable.h.


Constructor & Destructor Documentation

PLearn::RowAtPositionVariable::RowAtPositionVariable ( )

Default constructor for persistence.

Definition at line 56 of file RowAtPositionVariable.cc.

    : length_(-1)
{ }
PLearn::RowAtPositionVariable::RowAtPositionVariable ( Variable input1,
Variable input2,
int  the_length 
)

Definition at line 60 of file RowAtPositionVariable.cc.

References build_().

    : inherited(input1, input2, the_length, input1->width()), length_(the_length)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

RowAtPositionVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Implements PLearn::Variable.

Definition at line 108 of file RowAtPositionVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::matGradient.

{
    int i = (int)input2->valuedata[0];
    input1->gradient += matGradient(i);
}
void PLearn::RowAtPositionVariable::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::BinaryVariable.

Definition at line 67 of file RowAtPositionVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 74 of file RowAtPositionVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLERROR.

Referenced by build(), and RowAtPositionVariable().

{
    if (input1 && input2) {
        if(!input1->isRowVec())
            PLERROR("In RowAtPositionVariable: input1 must be a single row");
        if(!input2->isScalar())
            PLERROR("In RowAtPositionVariable: position must be a scalar");
    }
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file RowAtPositionVariable.cc.

void PLearn::RowAtPositionVariable::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::BinaryVariable.

Definition at line 85 of file RowAtPositionVariable.cc.

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

Here is the call graph for this function:

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 71 of file RowAtPositionVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file RowAtPositionVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 100 of file RowAtPositionVariable.cc.

References PLearn::TVec< T >::clear(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Variable::matValue, and PLearn::Variable::value.

{
    value.clear();
    int i = (int)input2->valuedata[0];
    matValue(i) << input1->value;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file RowAtPositionVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file RowAtPositionVariable.cc.

void PLearn::RowAtPositionVariable::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 91 of file RowAtPositionVariable.cc.

References PLearn::BinaryVariable::input1, length_, and PLearn::Var::width().

{
    l=length_;
    if (input1)
        w = input1->width();
    else
        w = 0;
}

Here is the call graph for this function:

void PLearn::RowAtPositionVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 121 of file RowAtPositionVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::TVec< T >::length(), PLearn::Variable::matRValue, PLearn::BinaryVariable::resizeRValue(), and PLearn::Variable::rValue.

{
    if (rValue.length()==0) resizeRValue();
    //rValue.clear();
    int i = (int)input2->valuedata[0];
    matRValue(i) << input1->rValue;
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 115 of file RowAtPositionVariable.cc.

References PLearn::Variable::g, PLearn::BinaryVariable::input1, and PLearn::BinaryVariable::input2.

{
    input1->accg(new VarRowVariable(g,input2));
}

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 71 of file RowAtPositionVariable.h.

Definition at line 64 of file RowAtPositionVariable.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