PLearn 0.1
|
adds a scalar constant to a matrix var More...
#include <PlusConstantVariable.h>
Public Member Functions | |
PlusConstantVariable () | |
Default constructor. | |
PlusConstantVariable (Variable *input, real c, bool call_build_=true) | |
Convenience constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual PlusConstantVariable * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual string | info () const |
Returns a bit more informative string about object (default returns classname()) | |
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_ () |
PlusConstantVariable. | |
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 () |
Public Attributes | |
real | cst |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Private Types | |
typedef UnaryVariable | inherited |
Private Member Functions | |
void | build_ () |
Object-specific post-constructor. |
adds a scalar constant to a matrix var
* Plus... *
Definition at line 57 of file PlusConstantVariable.h.
typedef UnaryVariable PLearn::PlusConstantVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file PlusConstantVariable.h.
PLearn::PlusConstantVariable::PlusConstantVariable | ( | ) |
string PLearn::PlusConstantVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
OptionList & PLearn::PlusConstantVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
RemoteMethodMap & PLearn::PlusConstantVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
Object * PLearn::PlusConstantVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
StaticInitializer PlusConstantVariable::_static_initializer_ & PLearn::PlusConstantVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
void PLearn::PlusConstantVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 115 of file PlusConstantVariable.cc.
References PLearn::Variable::gradientdata, PLearn::UnaryVariable::input, and PLearn::Variable::nelems().
{ for(int k=0; k<nelems(); k++) input->gradientdata[k] += gradientdata[k]; }
void PLearn::PlusConstantVariable::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 76 of file PlusConstantVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::PlusConstantVariable::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 84 of file PlusConstantVariable.cc.
Referenced by build(), and PlusConstantVariable().
{
// Nothing to do here.
}
string PLearn::PlusConstantVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
void PLearn::PlusConstantVariable::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::UnaryVariable.
Definition at line 91 of file PlusConstantVariable.cc.
References PLearn::OptionBase::buildoption, cst, PLearn::declareOption(), and PLearn::UnaryVariable::declareOptions().
{ inherited::declareOptions(ol); declareOption(ol, "cst", &PlusConstantVariable::cst, OptionBase::buildoption, "The constant to be added."); }
static const PPath& PLearn::PlusConstantVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 72 of file PlusConstantVariable.h.
PlusConstantVariable * PLearn::PlusConstantVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
void PLearn::PlusConstantVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 108 of file PlusConstantVariable.cc.
References cst, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
OptionList & PLearn::PlusConstantVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
OptionMap & PLearn::PlusConstantVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
RemoteMethodMap & PLearn::PlusConstantVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file PlusConstantVariable.cc.
virtual string PLearn::PlusConstantVariable::info | ( | ) | const [inline, virtual] |
Returns a bit more informative string about object (default returns classname())
Reimplemented from PLearn::Object.
Definition at line 76 of file PlusConstantVariable.h.
References PLearn::tostring().
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 99 of file PlusConstantVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::PlusConstantVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 129 of file PlusConstantVariable.cc.
References PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, and PLearn::Variable::rvaluedata.
{ if (rValue.length()==0) resizeRValue(); for(int k=0; k<nelems(); k++) rvaluedata[k] = input->rvaluedata[k]; }
void PLearn::PlusConstantVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 122 of file PlusConstantVariable.cc.
References PLearn::Variable::g, and PLearn::UnaryVariable::input.
Reimplemented from PLearn::UnaryVariable.
Definition at line 72 of file PlusConstantVariable.h.
Definition at line 63 of file PlusConstantVariable.h.
Referenced by declareOptions(), and fprop().