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

A convolve var; equals convolve(input, mask) More...

#include <ConvolveVariable.h>

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

List of all members.

Public Member Functions

 ConvolveVariable ()
 Default constructor for persistence.
 ConvolveVariable (Variable *input, Variable *mask)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ConvolveVariabledeepCopy (CopiesMap &copies) const
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

Static Public Member Functions

static string _classname_ ()
 ConvolveVariable.
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_

Private Types

typedef BinaryVariable inherited

Detailed Description

A convolve var; equals convolve(input, mask)

Definition at line 54 of file ConvolveVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 56 of file ConvolveVariable.h.


Constructor & Destructor Documentation

PLearn::ConvolveVariable::ConvolveVariable ( ) [inline]

Default constructor for persistence.

Definition at line 60 of file ConvolveVariable.h.

{}
PLearn::ConvolveVariable::ConvolveVariable ( Variable input,
Variable mask 
)

Definition at line 55 of file ConvolveVariable.cc.

    : inherited(input, mask, input->length()-mask->length()+1, input->width()-mask->width()+1)
{}

Member Function Documentation

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

ConvolveVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file ConvolveVariable.cc.

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

Implements PLearn::Variable.

Definition at line 76 of file ConvolveVariable.cc.

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

{
    for(int i=0; i<length(); i++) // size of matGradient
        for(int j=0; j<width(); j++)
        {
            real* input1valueptr = input1->matValue[i]+j;
            real* input2valueptr = input2->matValue.data();
        
            real thisgradient = matGradient(i,j);
            real* input1gradientptr = input1->matGradient[i]+j;
            real* input2gradientptr = input2->matGradient.data();
        
            for(int l=0; l<input2->length(); l++,
                    input1valueptr += input1->matValue.mod(), input2valueptr += input2->matValue.mod(),
                    input1gradientptr += input1->matGradient.mod(), input2gradientptr += input2->matGradient.mod())
                for(int c=0; c<input2->width(); c++)
                {
                    input1gradientptr[c] += thisgradient * input2valueptr[c];
                    input2gradientptr[c] += thisgradient * input1valueptr[c];
                }
        }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 63 of file ConvolveVariable.h.

{ return new ConvolveVariable(input, mask); }
ConvolveVariable * PLearn::ConvolveVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file ConvolveVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 70 of file ConvolveVariable.cc.

References PLearn::convolve(), PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::matValue.

{
    convolve(input1->matValue, input2->matValue, matValue);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConvolveVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file ConvolveVariable.cc.

void PLearn::ConvolveVariable::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 60 of file ConvolveVariable.cc.

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

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 100 of file ConvolveVariable.cc.

References PLERROR.

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

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 63 of file ConvolveVariable.h.


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