PLearn 0.1
|
#include <TraceVariable.h>
Public Member Functions | |
TraceVariable () | |
Default constructor. | |
TraceVariable (Variable *input, bool call_build_=true) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TraceVariable * | 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_ () |
TraceVariable. | |
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 48 of file TraceVariable.h.
typedef UnaryVariable PLearn::TraceVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 50 of file TraceVariable.h.
PLearn::TraceVariable::TraceVariable | ( | ) |
string PLearn::TraceVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
OptionList & PLearn::TraceVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
RemoteMethodMap & PLearn::TraceVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
Object * PLearn::TraceVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
StaticInitializer TraceVariable::_static_initializer_ & PLearn::TraceVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
void PLearn::TraceVariable::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 TraceVariable.cc.
References PLERROR.
{ PLERROR("bbprop not implemented for this variable"); }
void PLearn::TraceVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 103 of file TraceVariable.cc.
References PLearn::Variable::g, i, PLearn::UnaryVariable::input, PLearn::TMat< T >::length(), PLearn::Variable::matGradient, PLearn::min(), and PLearn::TMat< T >::width().
{ double g = matGradient(0,0); Mat G = input->gradientValue; int l = min(G.length(), G.width()); for(int i=0; i<l; i++) G(i,i) += g; }
void PLearn::TraceVariable::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 TraceVariable.cc.
References PLearn::UnaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::TraceVariable::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 TraceVariable.cc.
Referenced by build(), and TraceVariable().
{
// Nothing to do here.
}
string PLearn::TraceVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
static const PPath& PLearn::TraceVariable::declaringFile | ( | ) | [inline, static] |
TraceVariable * PLearn::TraceVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
void PLearn::TraceVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 93 of file TraceVariable.cc.
References i, PLearn::UnaryVariable::input, PLearn::TMat< T >::length(), PLearn::Variable::matValue, PLearn::min(), and PLearn::TMat< T >::width().
{ Mat V = input->matValue; int l = min(V.length(), V.width()); double result = 0; for(int i=0; i<l; i++) result += V(i,i); matValue(0,0) = result; }
OptionList & PLearn::TraceVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
OptionMap & PLearn::TraceVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.cc.
RemoteMethodMap & PLearn::TraceVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file TraceVariable.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 TraceVariable.cc.
{ l = w = 1; }
void PLearn::TraceVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 125 of file TraceVariable.cc.
References PLERROR.
{ PLERROR("rfprop no yet implemented for this vairable"); }
void PLearn::TraceVariable::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 TraceVariable.cc.
References PLERROR.
{ PLERROR("symbolic bprop not yet implemented for this variable"); }
Reimplemented from PLearn::UnaryVariable.
Definition at line 59 of file TraceVariable.h.