PLearn 0.1
|
#include <TimesRowVariable.h>
Public Member Functions | |
TimesRowVariable () | |
Default constructor. | |
TimesRowVariable (Variable *input1, Variable *input2, bool call_build_=true) | |
Convenience constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TimesRowVariable * | deepCopy (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 | 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_ () |
TimesRowVariable. | |
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 |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 52 of file TimesRowVariable.h.
typedef BinaryVariable PLearn::TimesRowVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file TimesRowVariable.h.
PLearn::TimesRowVariable::TimesRowVariable | ( | ) | [inline] |
string PLearn::TimesRowVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file TimesRowVariable.cc.
OptionList & PLearn::TimesRowVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file TimesRowVariable.cc.
RemoteMethodMap & PLearn::TimesRowVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file TimesRowVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file TimesRowVariable.cc.
Object * PLearn::TimesRowVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 57 of file TimesRowVariable.cc.
StaticInitializer TimesRowVariable::_static_initializer_ & PLearn::TimesRowVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file TimesRowVariable.cc.
void PLearn::TimesRowVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 118 of file TimesRowVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::length(), and PLearn::Variable::width().
{ int k=0; for(int i=0; i<length(); i++) for(int j=0; j<width(); j++, k++) { input1->gradientdata[k] += input2->valuedata[j]*gradientdata[k]; input2->gradientdata[j] += input1->valuedata[k]*gradientdata[k]; } }
void PLearn::TimesRowVariable::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 73 of file TimesRowVariable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::TimesRowVariable::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 82 of file TimesRowVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLCHECK_MSG, and PLearn::Var::width().
Referenced by build(), and TimesRowVariable().
{ if (input1 && input2) { PLCHECK_MSG(input2->isRowVec(), "input1 must be a row vector"); PLCHECK_MSG(input2->width() == input1->width(), "input1 and input2 must have same width"); } }
string PLearn::TimesRowVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file TimesRowVariable.cc.
static const PPath& PLearn::TimesRowVariable::declaringFile | ( | ) | [inline, static] |
TimesRowVariable * PLearn::TimesRowVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file TimesRowVariable.cc.
void PLearn::TimesRowVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 107 of file TimesRowVariable.cc.
References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::length(), PLearn::Variable::valuedata, and PLearn::Variable::width().
{ int k=0; for(int i=0; i<length(); i++) for(int j=0; j<width(); j++, k++) valuedata[k] = input1->valuedata[k] * input2->valuedata[j]; }
OptionList & PLearn::TimesRowVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file TimesRowVariable.cc.
OptionMap & PLearn::TimesRowVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file TimesRowVariable.cc.
RemoteMethodMap & PLearn::TimesRowVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file TimesRowVariable.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 95 of file TimesRowVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::TimesRowVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 141 of file TimesRowVariable.cc.
References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::TVec< T >::length(), PLearn::Variable::length(), PLearn::BinaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, and PLearn::Variable::width().
{ if (rValue.length()==0) resizeRValue(); int k=0; for(int i=0; i<length(); i++) for(int j=0; j<width(); j++, k++) rvaluedata[k] = input1->rvaluedata[k] * input2->valuedata[j] + input1->valuedata[k] * input2->rvaluedata[j]; }
void PLearn::TimesRowVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 132 of file TimesRowVariable.cc.
References PLearn::columnSum(), PLearn::Variable::g, PLearn::BinaryVariable::input1, and PLearn::BinaryVariable::input2.
Reimplemented from PLearn::BinaryVariable.
Definition at line 65 of file TimesRowVariable.h.