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

Affine transformation of a MATRIX variable. More...

#include <MatrixAffineTransformVariable.h>

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

List of all members.

Public Member Functions

 MatrixAffineTransformVariable ()
 Default constructor for persistence.
 MatrixAffineTransformVariable (Variable *mat, Variable *transformation)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
MatrixAffineTransformVariable
deepCopy (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_ ()
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

Affine transformation of a MATRIX variable.

Should work for both column and row vectors: result vector will be of same kind (row or col) First row of transformation matrix contains bias b, following rows contain linear-transformation T Will compute b + x.T which is equivalent to b +

Definition at line 57 of file MatrixAffineTransformVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file MatrixAffineTransformVariable.h.


Constructor & Destructor Documentation

PLearn::MatrixAffineTransformVariable::MatrixAffineTransformVariable ( ) [inline]

Default constructor for persistence.

Definition at line 63 of file MatrixAffineTransformVariable.h.

{}
PLearn::MatrixAffineTransformVariable::MatrixAffineTransformVariable ( Variable mat,
Variable transformation 
) [inline]

Definition at line 64 of file MatrixAffineTransformVariable.h.

        : inherited(mat, transformation, transformation->width(), mat->width())
    {}

Member Function Documentation

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Implements PLearn::Variable.

Definition at line 76 of file MatrixAffineTransformVariable.cc.

References PLearn::TMat< T >::firstRow(), i, j, PLearn::TMat< T >::length(), PLearn::productAcc(), PLearn::productTransposeAcc(), and PLearn::TMat< T >::subMatRows().

{
    Mat&  afftr = input2->matValue;
    int l = afftr.length();
    Mat lintr = afftr.subMatRows(1,l-1);

    Mat& afftr_g = input2->matGradient;
    Vec bias_g = afftr_g.firstRow();
    Mat lintr_g = afftr_g.subMatRows(1,l-1);

    for (int i = 0; i < length(); i++)
        for (int j = 0; j < width(); j++)
        {
            bias_g[i] += matGradient[i][j];
        }
    if(!input1->dont_bprop_here)      
        productAcc(input1->matGradient, lintr, matGradient);
    productTransposeAcc(lintr_g, input1->matValue, matGradient);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 68 of file MatrixAffineTransformVariable.h.

MatrixAffineTransformVariable * PLearn::MatrixAffineTransformVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 66 of file MatrixAffineTransformVariable.cc.

References i, j, PLearn::TMat< T >::subMatRows(), and PLearn::transposeProductAcc().

{
    Mat lintransform = input2->matValue.subMatRows(1,input2->length()-1);
    for (int i = 0; i < length(); i++)
        for (int j = 0; j < width(); j++)
            matValue[i][j] = input2->matValue[0][i];
    transposeProductAcc(matValue,lintransform, input1->matValue);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 54 of file MatrixAffineTransformVariable.cc.

void PLearn::MatrixAffineTransformVariable::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 56 of file MatrixAffineTransformVariable.cc.

{
    if (input1 && input2) {
        l = input2->width();
        w = input1->width();
    } else
        l = w = 0;
}
void PLearn::MatrixAffineTransformVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 97 of file MatrixAffineTransformVariable.cc.

References PLearn::Variable::accg(), and g.

{
    Var lintr = new SubMatVariable(input2,0,0,input2->length()-1,input2->width());
    //Var bias = new SubMatVariable(input2,length()-1,0,1,width());

    if(!input1->dont_bprop_here)
        input1->accg(new ProductVariable(lintr,g));
    input2->accg(new MatrixAffineTransformFeedbackVariable(input1,g));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 68 of file MatrixAffineTransformVariable.h.


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