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

adds a single-column var to each column of a matrix var More...

#include <PlusColumnVariable.h>

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

List of all members.

Public Member Functions

 PlusColumnVariable ()
 Default constructor for persistence.
 PlusColumnVariable (Variable *input1, Variable *input2)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual PlusColumnVariabledeepCopy (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 bbprop ()
 compute an approximation to diag(d^2/dinput^2) given diag(d^2/doutput^2), with diag(d^2/dinput^2) ~=~ (doutput/dinput)' diag(d^2/doutput^2) (doutput/dinput) In particular: if 'C' depends on 'y' and 'y' depends on x ...
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_ ()
 PlusColumnVariable.
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_

Protected Member Functions

void build_ ()
 This does the actual building.

Private Types

typedef BinaryVariable inherited

Detailed Description

adds a single-column var to each column of a matrix var

Definition at line 53 of file PlusColumnVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 55 of file PlusColumnVariable.h.


Constructor & Destructor Documentation

PLearn::PlusColumnVariable::PlusColumnVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file PlusColumnVariable.h.

{}
PLearn::PlusColumnVariable::PlusColumnVariable ( Variable input1,
Variable input2 
)

Definition at line 56 of file PlusColumnVariable.cc.

References build_().

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

Here is the call graph for this function:


Member Function Documentation

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

PlusColumnVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file PlusColumnVariable.cc.

void PLearn::PlusColumnVariable::bbprop ( ) [virtual]

compute an approximation to diag(d^2/dinput^2) given diag(d^2/doutput^2), with diag(d^2/dinput^2) ~=~ (doutput/dinput)' diag(d^2/doutput^2) (doutput/dinput) In particular: if 'C' depends on 'y' and 'y' depends on x ...

d^2C/dx^2 = d^2C/dy^2 * (dy/dx)^2 + dC/dy * d^2y/dx^2 (diaghessian) (gradient)

Reimplemented from PLearn::Variable.

Definition at line 112 of file PlusColumnVariable.cc.

References PLearn::Variable::diaghessiandata, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Var::length(), PLearn::Variable::length(), and PLearn::Variable::width().

{
    if (input1->diaghessian.length()==0)
        input1->resizeDiagHessian();
    if (input2->diaghessian.length()==0)
        input2->resizeDiagHessian();
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
        {
            input1->diaghessiandata[k] += diaghessiandata[k];
            input2->diaghessiandata[i] += diaghessiandata[k];
        }
}

Here is the call graph for this function:

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

Implements PLearn::Variable.

Definition at line 100 of file PlusColumnVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::length(), and PLearn::Variable::width().

{
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
        {
            input1->gradientdata[k] += gradientdata[k];
            input2->gradientdata[i] += gradientdata[k];
        }
}

Here is the call graph for this function:

void PLearn::PlusColumnVariable::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 63 of file PlusColumnVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 70 of file PlusColumnVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), and PLERROR.

Referenced by build(), and PlusColumnVariable().

{
    if (input1 && input2) {
        if(!input2->isColumnVec())
            PLERROR("IN PlusColumnVariable: input2 is not a column");
        if(input2->length() != input1->length())
            PLERROR("IN PlusColumnVariable: input1 and input2 have a different length()");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file PlusColumnVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file PlusColumnVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 91 of file PlusColumnVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::length(), PLearn::Variable::valuedata, and PLearn::Variable::width().

{
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
            valuedata[k] = input1->valuedata[k] + input2->valuedata[i];
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file PlusColumnVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file PlusColumnVariable.cc.

void PLearn::PlusColumnVariable::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 81 of file PlusColumnVariable.cc.

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

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Variable.

Definition at line 135 of file PlusColumnVariable.cc.

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

{
    if (rValue.length()==0) resizeRValue();
    int k=0;
    for(int i=0; i<length(); i++)
        for(int j=0; j<width(); j++, k++)
            rvaluedata[k] = input1->rvaluedata[k] + input2->rvaluedata[i];
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 128 of file PlusColumnVariable.cc.

References PLearn::Variable::g, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::rowSum().

{
    input1->accg(g);
    input2->accg(rowSum(g));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file PlusColumnVariable.h.


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