PLearn 0.1
|
#include <DivVariable.h>
Public Member Functions | |
DivVariable () | |
Default constructor. | |
DivVariable (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 DivVariable * | 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_ () |
DivVariable. | |
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 DivVariable.h.
typedef BinaryVariable PLearn::DivVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file DivVariable.h.
PLearn::DivVariable::DivVariable | ( | ) | [inline] |
string PLearn::DivVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file DivVariable.cc.
OptionList & PLearn::DivVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file DivVariable.cc.
RemoteMethodMap & PLearn::DivVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file DivVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file DivVariable.cc.
Object * PLearn::DivVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 57 of file DivVariable.cc.
StaticInitializer DivVariable::_static_initializer_ & PLearn::DivVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file DivVariable.cc.
void PLearn::DivVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 107 of file DivVariable.cc.
References PLearn::Variable::gradientdata, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::nelems().
{ for(int k=0; k<nelems(); k++) { real iv2k = 1.0/input2->valuedata[k]; input1->gradientdata[k] += gradientdata[k] * iv2k; input2->gradientdata[k] -= gradientdata[k] * input1->valuedata[k] * iv2k * iv2k; } }
void PLearn::DivVariable::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 84 of file DivVariable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::DivVariable::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 93 of file DivVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLERROR, and PLearn::Var::width().
Referenced by build(), and DivVariable().
{ if (input1 && input2) if(input1->length() != input2->length() || input1->width() != input2->width()) PLERROR("In DivVariable: input1 and input2 must have exactly the same shape"); }
string PLearn::DivVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file DivVariable.cc.
static const PPath& PLearn::DivVariable::declaringFile | ( | ) | [inline, static] |
DivVariable * PLearn::DivVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file DivVariable.cc.
void PLearn::DivVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 100 of file DivVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
OptionList & PLearn::DivVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file DivVariable.cc.
OptionMap & PLearn::DivVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file DivVariable.cc.
RemoteMethodMap & PLearn::DivVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 57 of file DivVariable.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 72 of file DivVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::DivVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 127 of file DivVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::TVec< T >::length(), PLearn::Variable::nelems(), PLearn::BinaryVariable::resizeRValue(), PLearn::Variable::rValue, and PLearn::Variable::rvaluedata.
{ if (rValue.length()==0) resizeRValue(); for(int k=0; k<nelems(); k++) { real iv2k = 1.0/input2->valuedata[k]; rvaluedata[k] = input1->rvaluedata[k] * iv2k - input2->rvaluedata[k] * input1->valuedata[k] * iv2k * iv2k; } }
void PLearn::DivVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 119 of file DivVariable.cc.
References PLearn::Variable::g, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::invertElements(), and PLearn::square().
{ Var iv2 = invertElements(input2); input1->accg(g * iv2); input2->accg(-g * input1 * square(iv2)); }
Reimplemented from PLearn::BinaryVariable.
Definition at line 64 of file DivVariable.h.