PLearn 0.1
|
adds 2 matrix vars of same size More...
#include <PlusVariable.h>
Public Member Functions | |
PlusVariable () | |
Default constructor for persistence. | |
PlusVariable (Variable *input1, Variable *input2) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual PlusVariable * | 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 | 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 | |
Static Public Member Functions | |
static string | _classname_ () |
PlusVariable. | |
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. |
adds 2 matrix vars of same size
Definition at line 53 of file PlusVariable.h.
typedef BinaryVariable PLearn::PlusVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 55 of file PlusVariable.h.
PLearn::PlusVariable::PlusVariable | ( | ) | [inline] |
string PLearn::PlusVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file PlusVariable.cc.
OptionList & PLearn::PlusVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file PlusVariable.cc.
RemoteMethodMap & PLearn::PlusVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file PlusVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file PlusVariable.cc.
Object * PLearn::PlusVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 53 of file PlusVariable.cc.
StaticInitializer PlusVariable::_static_initializer_ & PLearn::PlusVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file PlusVariable.cc.
void PLearn::PlusVariable::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 104 of file PlusVariable.cc.
References PLearn::Variable::diaghessiandata, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), and PLearn::Variable::nelems().
{ if (input1->diaghessian.length()==0) input1->resizeDiagHessian(); if (input2->diaghessian.length()==0) input2->resizeDiagHessian(); for(int k=0; k<nelems(); k++) { input1->diaghessiandata[k] += diaghessiandata[k]; input2->diaghessiandata[k] += diaghessiandata[k]; } }
void PLearn::PlusVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 94 of file PlusVariable.cc.
References PLearn::Variable::gradientdata, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::nelems().
{ for(int k=0; k<nelems(); k++) { input1->gradientdata[k] += gradientdata[k]; input2->gradientdata[k] += gradientdata[k]; } }
void PLearn::PlusVariable::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 62 of file PlusVariable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::PlusVariable::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 69 of file PlusVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLERROR, and PLearn::Var::width().
Referenced by build(), and PlusVariable().
{ if (input1 && input2) { if(input1->size() != input2->size()) PLERROR("In PlusVariable: input1 and input2 must have exactly the same size (%ix%i != %ix%i)", input1->length(), input1->width(), input2->length(), input2->width()); } }
string PLearn::PlusVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file PlusVariable.cc.
static const PPath& PLearn::PlusVariable::declaringFile | ( | ) | [inline, static] |
PlusVariable * PLearn::PlusVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file PlusVariable.cc.
void PLearn::PlusVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 87 of file PlusVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
OptionList & PLearn::PlusVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file PlusVariable.cc.
OptionMap & PLearn::PlusVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file PlusVariable.cc.
RemoteMethodMap & PLearn::PlusVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file PlusVariable.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 78 of file PlusVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::PlusVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 118 of file PlusVariable.cc.
References PLearn::Variable::g, PLearn::BinaryVariable::input1, and PLearn::BinaryVariable::input2.
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file PlusVariable.h.