PLearn 0.1
|
#include <TransposeVariable.h>
Public Member Functions | |
TransposeVariable () | |
Default constructor for persistence. | |
TransposeVariable (Variable *v) | |
TransposeVariable. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TransposeVariable * | 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 () |
Nothing to do by default. | |
virtual void | bprop () |
Nothing to do by default. | |
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_ () |
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_ |
Protected Attributes | |
int | startk |
Private Types | |
typedef UnaryVariable | inherited |
Definition at line 11 of file TransposeVariable.h.
typedef UnaryVariable PLearn::TransposeVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 14 of file TransposeVariable.h.
PLearn::TransposeVariable::TransposeVariable | ( | ) | [inline] |
Default constructor for persistence.
Definition at line 19 of file TransposeVariable.h.
: startk(0) {}
PLearn::TransposeVariable::TransposeVariable | ( | Variable * | v | ) |
Definition at line 11 of file TransposeVariable.cc.
:UnaryVariable(v, v->width(), v->length()), startk(0) {}
string PLearn::TransposeVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
OptionList & PLearn::TransposeVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
RemoteMethodMap & PLearn::TransposeVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
Object * PLearn::TransposeVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
StaticInitializer TransposeVariable::_static_initializer_ & PLearn::TransposeVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
void PLearn::TransposeVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 51 of file TransposeVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, j, PLearn::Var::length(), PLearn::Variable::length(), PLearn::Variable::nelems(), PLearn::Variable::width(), and PLearn::Var::width().
{ if(input->length()==1 || input->width()==1) { real* inputdata = input->gradientdata; for(int k=0; k<nelems(); k++) inputdata[k] += gradientdata[k]; } else // general case { real* inputrowdata = input->gradientdata; int thiskcolstart = 0; // element index of start of column in this var for(int i=0; i<width(); i++) // the width() of this var is the length() of the submat { int thisk = thiskcolstart++; for(int j=0; j<length(); j++, thisk+=width()) // the length() of this var is the width() of the submat *inputrowdata++ += gradientdata[thisk]; } } }
string PLearn::TransposeVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
static const PPath& PLearn::TransposeVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 26 of file TransposeVariable.h.
{ return new TransposeVariable(v); }
TransposeVariable * PLearn::TransposeVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
void PLearn::TransposeVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 29 of file TransposeVariable.cc.
References i, PLearn::UnaryVariable::input, j, PLearn::Var::length(), PLearn::Variable::length(), PLearn::Variable::nelems(), PLearn::Variable::valuedata, PLearn::Variable::width(), and PLearn::Var::width().
{ if(input->length()==1 || input->width()==1) { real* inputdata = input->valuedata; for(int k=0; k<nelems(); k++) valuedata[k] = inputdata[k]; } else // general case { real* inputrowdata = input->valuedata; int thiskcolstart = 0; // element index of start of column in this var for(int i=0; i<width(); i++) // the width() of this var is the length() of the submat { int thisk = thiskcolstart++; for(int j=0; j<length(); j++, thisk+=width()) // the length() of this var is the width() of the submat valuedata[thisk] = *inputrowdata++; } } }
OptionList & PLearn::TransposeVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
OptionMap & PLearn::TransposeVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.cc.
RemoteMethodMap & PLearn::TransposeVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 16 of file TransposeVariable.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 19 of file TransposeVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::TransposeVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 88 of file TransposeVariable.cc.
References PLERROR.
{ PLERROR("Not implemented yet!"); /* if (rValue.length()==0) resizeRValue(); if(input->length()==1 || input->width()==1) // optimized version for this special case... { real* inputdata = input->rvaluedata+startk; for(int k=0; k<nelems(); k++) rvaluedata[k] = inputdata[k]; } else // general case { real* inputrowdata = input->rvaluedata+startk; int thiskcolstart = 0; // element index of start of column in this var for(int i=0; i<width(); i++) // the width() of this var is the length() of the submat { int thisk = thiskcolstart++; for(int j=0; j<length(); j++, thisk+=width()) // the length() of this var is the width() of the submat rvaluedata[thisk] = inputrowdata[j]; inputrowdata += input->width(); } } */ }
void PLearn::TransposeVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 73 of file TransposeVariable.cc.
References PLERROR.
{ PLERROR("Not implemented yet!"); /* int i = startk/input->width(); int j = startk%input->width(); int topextent = i; int bottomextent = input->length()-(i+width()); // the width() of this var is the length() of the submat int leftextent = j; int rightextent = input->width()-(j+length()); // the length() of this var is the width() of the submat input->accg(extend(transpose(g),topextent,bottomextent,leftextent,rightextent)); */ }
Reimplemented from PLearn::UnaryVariable.
Definition at line 26 of file TransposeVariable.h.
int PLearn::TransposeVariable::startk [protected] |
Definition at line 22 of file TransposeVariable.h.