PLearn 0.1
|
Compute the sum of all elements in the input Var. More...
#include <SumVariable.h>
Public Member Functions | |
SumVariable () | |
Default constructor for persistence. | |
SumVariable (Variable *input) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SumVariable * | deepCopy (CopiesMap &copies) const |
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_ () |
SumVariable. | |
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 |
Compute the sum of all elements in the input Var.
This Variable returns the sum of all elements of its single input Variable.
Definition at line 59 of file SumVariable.h.
typedef UnaryVariable PLearn::SumVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 61 of file SumVariable.h.
PLearn::SumVariable::SumVariable | ( | ) | [inline] |
PLearn::SumVariable::SumVariable | ( | Variable * | input | ) |
Definition at line 62 of file SumVariable.cc.
string PLearn::SumVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
OptionList & PLearn::SumVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
RemoteMethodMap & PLearn::SumVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
Object * PLearn::SumVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
StaticInitializer SumVariable::_static_initializer_ & PLearn::SumVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
void PLearn::SumVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 78 of file SumVariable.cc.
References PLearn::Variable::gradientdata, and PLearn::UnaryVariable::input.
{ real grd = gradientdata[0]; for(int k=0; k<input->nelems(); k++) input->gradientdata[k] += grd; }
string PLearn::SumVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
static const PPath& PLearn::SumVariable::declaringFile | ( | ) | [inline, static] |
SumVariable * PLearn::SumVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
void PLearn::SumVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 69 of file SumVariable.cc.
References PLearn::UnaryVariable::input, PLearn::sum(), and PLearn::Variable::valuedata.
{ real sum = 0.0; for(int k=0; k<input->nelems(); k++) sum += input->valuedata[k]; valuedata[0] = sum; }
OptionList & PLearn::SumVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
OptionMap & PLearn::SumVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.cc.
RemoteMethodMap & PLearn::SumVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 60 of file SumVariable.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 66 of file SumVariable.cc.
{ l=1; w=1; }
void PLearn::SumVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 93 of file SumVariable.cc.
References PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, and PLearn::sum().
{ if (rValue.length()==0) resizeRValue(); real sum = 0.0; for(int k=0; k<input->nelems(); k++) sum += input->rvaluedata[k]; rvaluedata[0] = sum; }
void PLearn::SumVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 86 of file SumVariable.cc.
References PLearn::Variable::g, and PLearn::UnaryVariable::input.
Reimplemented from PLearn::UnaryVariable.
Definition at line 68 of file SumVariable.h.