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

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

#include <ProductTransposeVariable.h>

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

List of all members.

Public Member Functions

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

Definition at line 53 of file ProductTransposeVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 55 of file ProductTransposeVariable.h.


Constructor & Destructor Documentation

PLearn::ProductTransposeVariable::ProductTransposeVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file ProductTransposeVariable.h.

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

Definition at line 60 of file ProductTransposeVariable.cc.

References build_().

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

Here is the call graph for this function:


Member Function Documentation

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

ProductTransposeVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file ProductTransposeVariable.cc.

void PLearn::ProductTransposeVariable::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 111 of file ProductTransposeVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLearn::Variable::matGradient, PLearn::product2Acc(), and PLearn::transposeProduct2Acc().

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

Here is the call graph for this function:

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

Implements PLearn::Variable.

Definition at line 102 of file ProductTransposeVariable.cc.

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

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

Here is the call graph for this function:

void PLearn::ProductTransposeVariable::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 ProductTransposeVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 74 of file ProductTransposeVariable.cc.

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

Referenced by build(), and ProductTransposeVariable().

{
    if (input1 && input2) {
        // input1 and input2 are (respectively) m1 and m2 from constructor
        if (input1->width() != input2->width())
            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::ProductTransposeVariable::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ProductTransposeVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file ProductTransposeVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 95 of file ProductTransposeVariable.cc.

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

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 58 of file ProductTransposeVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 58 of file ProductTransposeVariable.cc.

void PLearn::ProductTransposeVariable::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 84 of file ProductTransposeVariable.cc.

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

{
    if (input1 && input2) {
        if (input1->width() != input2->width())
            PLERROR("In ProductVariable: the size of m1 and m2 are not compatible for a matrix product");
        l = input1->length();
        w = input2->length();
    } else
        l = w = 0;
}

Here is the call graph for this function:

void PLearn::ProductTransposeVariable::rfprop ( ) [virtual]
void PLearn::ProductTransposeVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 124 of file ProductTransposeVariable.cc.

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

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

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 62 of file ProductTransposeVariable.h.


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