PLearn 0.1
|
#include <SquareVariable.h>
Public Member Functions | |
SquareVariable () | |
Default constructor. | |
SquareVariable (Variable *input, bool call_build_=true) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SquareVariable * | 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 () |
Nothing to do by default. | |
virtual void | bprop () |
Nothing to do by default. | |
virtual void | bbprop () |
here don't approximate, do d2C/dx^2 = 4 x^2 d2C/dy^2 + 2 dC/dy | |
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_ () |
SquareVariable. | |
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 UnaryVariable | inherited |
Private Member Functions | |
void | build_ () |
Object-specific post-constructor. |
Definition at line 52 of file SquareVariable.h.
typedef UnaryVariable PLearn::SquareVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 54 of file SquareVariable.h.
PLearn::SquareVariable::SquareVariable | ( | ) | [inline] |
string PLearn::SquareVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
OptionList & PLearn::SquareVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
RemoteMethodMap & PLearn::SquareVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
Object * PLearn::SquareVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
StaticInitializer SquareVariable::_static_initializer_ & PLearn::SquareVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
void PLearn::SquareVariable::bbprop | ( | ) | [virtual] |
here don't approximate, do d2C/dx^2 = 4 x^2 d2C/dy^2 + 2 dC/dy
Reimplemented from PLearn::Variable.
Definition at line 113 of file SquareVariable.cc.
References PLearn::Variable::diaghessiandata, PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, PLearn::Var::length(), n, and PLearn::Variable::nelems().
{ if (input->diaghessian.length()==0) input->resizeDiagHessian(); int n=nelems(); for(int i=0; i<n; i++) { real input_i = input->valuedata[i]; input->diaghessiandata[i] += 4.0 * input_i * input_i * diaghessiandata[i] + 2.0 * gradientdata[i]; } }
void PLearn::SquareVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 105 of file SquareVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, n, and PLearn::Variable::nelems().
{ int n=nelems(); for(int i=0; i<n; i++) input->gradientdata[i] += 2.0 * input->valuedata[i] * gradientdata[i]; }
void PLearn::SquareVariable::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::UnaryVariable.
Definition at line 72 of file SquareVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::SquareVariable::build_ | ( | ) | [private] |
Object-specific post-constructor.
This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build()
method, and possibly the public virtual read method (which calls its parent's read). build_()
can assume that its parent's build_()
has already been called.
Reimplemented from PLearn::UnaryVariable.
Definition at line 80 of file SquareVariable.cc.
Referenced by build(), and SquareVariable().
{
// Nothing to do here.
}
string PLearn::SquareVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
static const PPath& PLearn::SquareVariable::declaringFile | ( | ) | [inline, static] |
SquareVariable * PLearn::SquareVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
void PLearn::SquareVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 97 of file SquareVariable.cc.
References i, PLearn::UnaryVariable::input, n, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
OptionList & PLearn::SquareVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
OptionMap & PLearn::SquareVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.cc.
RemoteMethodMap & PLearn::SquareVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 57 of file SquareVariable.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 87 of file SquareVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::SquareVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 133 of file SquareVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), n, PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, and PLearn::Variable::rvaluedata.
{ if (rValue.length()==0) resizeRValue(); int n=nelems(); for(int i=0; i<n; i++) rvaluedata[i] = 2*input->valuedata[i]*input->rvaluedata[i]; }
void PLearn::SquareVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 127 of file SquareVariable.cc.
References PLearn::Variable::g, and PLearn::UnaryVariable::input.
Reimplemented from PLearn::UnaryVariable.
Definition at line 62 of file SquareVariable.h.