PLearn 0.1
|
#include <AbsVariable.h>
Public Member Functions | |
AbsVariable () | |
Default constructor for persistence. | |
AbsVariable (Variable *input) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual AbsVariable * | 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_ () |
AbsVariable. | |
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 |
Definition at line 53 of file AbsVariable.h.
typedef UnaryVariable PLearn::AbsVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 55 of file AbsVariable.h.
PLearn::AbsVariable::AbsVariable | ( | ) | [inline] |
PLearn::AbsVariable::AbsVariable | ( | Variable * | input | ) |
string PLearn::AbsVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
OptionList & PLearn::AbsVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
RemoteMethodMap & PLearn::AbsVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
Object * PLearn::AbsVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
StaticInitializer AbsVariable::_static_initializer_ & PLearn::AbsVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
void PLearn::AbsVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 84 of file AbsVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, and PLearn::Variable::nelems().
{ for(int i=0; i<nelems(); i++) { real val = input->valuedata[i]; if(val>=0) input->gradientdata[i] += gradientdata[i]; else input->gradientdata[i] -= gradientdata[i]; } }
string PLearn::AbsVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
static const PPath& PLearn::AbsVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 62 of file AbsVariable.h.
{ return new AbsVariable(v); }
AbsVariable * PLearn::AbsVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
void PLearn::AbsVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 74 of file AbsVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), and PLearn::Variable::valuedata.
{ for(int i=0; i<nelems(); i++) { real val = input->valuedata[i]; valuedata[i] = val>=0 ?val :-val; } }
OptionList & PLearn::AbsVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
OptionMap & PLearn::AbsVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.cc.
RemoteMethodMap & PLearn::AbsVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file AbsVariable.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 65 of file AbsVariable.cc.
References PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::AbsVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 105 of file AbsVariable.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++) if (input->valuedata[i] < 0) rvaluedata[i] = -input->rvaluedata[i]; else rvaluedata[i] = input->rvaluedata[i]; }
void PLearn::AbsVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 97 of file AbsVariable.cc.
References PLearn::Variable::g, PLearn::ifThenElse(), and PLearn::UnaryVariable::input.
{ input->accg(ifThenElse(input >= 0., g, -g)); }
Reimplemented from PLearn::UnaryVariable.
Definition at line 62 of file AbsVariable.h.