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

Matrix product between transpose of matrix1 and matrix2. More...

#include <TransposeProductVariable.h>

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

List of all members.

Public Member Functions

 TransposeProductVariable ()
 Default constructor for persistence.
 TransposeProductVariable (Variable *matrix1, Variable *matrix2)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TransposeProductVariabledeepCopy (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_ ()
 TransposeProductVariable.
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

Matrix product between transpose of matrix1 and matrix2.

Definition at line 53 of file TransposeProductVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 55 of file TransposeProductVariable.h.


Constructor & Destructor Documentation

PLearn::TransposeProductVariable::TransposeProductVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file TransposeProductVariable.h.

{}
PLearn::TransposeProductVariable::TransposeProductVariable ( Variable matrix1,
Variable matrix2 
)

Definition at line 59 of file TransposeProductVariable.cc.

References build_().

    : inherited(m1, m2, m1->width(), m2->width())
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

TransposeProductVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 57 of file TransposeProductVariable.cc.

void PLearn::TransposeProductVariable::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 107 of file TransposeProductVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLearn::Variable::matGradient, PLearn::squareProductAcc(), and PLearn::squareProductTransposeAcc().

{
    if (input1->diaghessian.length()==0)
        input1->resizeDiagHessian();
    if (input2->diaghessian.length()==0)
        input2->resizeDiagHessian();
    // d^2C/dinput1[k,i]^2 += sum_j input2[k,j]^2 dC/dm[i,j] 
    squareProductTransposeAcc(input1->matGradient, input2->matValue,matGradient);
    // d^2C/dinput2[k,j]^2 += sum_i input1[k,i]^2 dC/dm[i,j] 
    squareProductAcc(input2->matGradient, input1->matValue,matGradient);
}

Here is the call graph for this function:

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

Implements PLearn::Variable.

Definition at line 98 of file TransposeProductVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Variable::matGradient, PLearn::productAcc(), and PLearn::productTransposeAcc().

{
    // dC/dinput1[k,i] += sum_j input2[k,j] dC/dm[i,j] 
    productTransposeAcc(input1->matGradient, input2->matValue,matGradient);
    // dC/dinput2[k,j] += sum_i input1[k,i] dC/dm[i,j] 
    productAcc(input2->matGradient, input1->matValue,matGradient);
}

Here is the call graph for this function:

void PLearn::TransposeProductVariable::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 66 of file TransposeProductVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 73 of file TransposeProductVariable.cc.

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

Referenced by build(), and TransposeProductVariable().

{
    if (input1 && input2) {
        // input1 and input2 are (respectively) m1 and m2 from constructor
        if (input1->length() != input2->length())
            PLERROR("In ProductVariable: the size of m1 and m2 are not compatible for a matrix product");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file TransposeProductVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 57 of file TransposeProductVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 91 of file TransposeProductVariable.cc.

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

{
    // m[i,j] = sum_k input1[k,i] * input2[k,j]
    transposeProduct(matValue, input1->matValue,input2->matValue);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 57 of file TransposeProductVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 57 of file TransposeProductVariable.cc.

void PLearn::TransposeProductVariable::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 82 of file TransposeProductVariable.cc.

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

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Variable.

Definition at line 129 of file TransposeProductVariable.cc.

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

{
    if (rValue.length()==0) resizeRValue();
    // m[i,j] = sum_k input1[k,i] * input2[k,j]
    transposeProduct(matRValue, input1->matRValue,input2->matValue);
    transposeProductAcc(matRValue, input1->matValue,input2->matRValue);
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 120 of file TransposeProductVariable.cc.

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

{
    // dC/dinput1[k,i] += sum_j input2[k,j] dC/dm[i,j] 
    input1->accg(productTranspose(input2,g));
    // dC/dinput2[k,j] += sum_i input1[k,i] dC/dm[i,j] 
    input2->accg(product(input1, g));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file TransposeProductVariable.h.


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