PLearn 0.1
|
Affine transformation of a MATRIX variable. More...
#include <MatrixAffineTransformVariable.h>
Public Member Functions | |
MatrixAffineTransformVariable () | |
Default constructor for persistence. | |
MatrixAffineTransformVariable (Variable *mat, Variable *transformation) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () 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 PPath & | declaringFile () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Private Types | |
typedef BinaryVariable | inherited |
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.
typedef BinaryVariable PLearn::MatrixAffineTransformVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 59 of file MatrixAffineTransformVariable.h.
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()) {}
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.
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); }
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); }
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.
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.
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)); }
Reimplemented from PLearn::BinaryVariable.
Definition at line 68 of file MatrixAffineTransformVariable.h.