PLearn 0.1
|
#include <IndexAtPositionVariable.h>
Public Member Functions | |
IndexAtPositionVariable () | |
Default constructor for persistence. | |
IndexAtPositionVariable (Variable *input1, Variable *input2, int the_length, int the_width) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual IndexAtPositionVariable * | 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 () |
compute output given input | |
virtual void | bprop () |
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_ () |
IndexAtPositionVariable. | |
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 void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
void | build_ () |
This does the actual building. | |
Protected Attributes | |
int | length_ |
int | width_ |
Private Types | |
typedef BinaryVariable | inherited |
Definition at line 52 of file IndexAtPositionVariable.h.
typedef BinaryVariable PLearn::IndexAtPositionVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.h.
PLearn::IndexAtPositionVariable::IndexAtPositionVariable | ( | ) |
Default constructor for persistence.
Definition at line 57 of file IndexAtPositionVariable.cc.
string PLearn::IndexAtPositionVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.cc.
OptionList & PLearn::IndexAtPositionVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.cc.
RemoteMethodMap & PLearn::IndexAtPositionVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.cc.
Object * PLearn::IndexAtPositionVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 54 of file IndexAtPositionVariable.cc.
StaticInitializer IndexAtPositionVariable::_static_initializer_ & PLearn::IndexAtPositionVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.cc.
void PLearn::IndexAtPositionVariable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 108 of file IndexAtPositionVariable.cc.
References PLearn::Variable::gradientdata, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, and PLearn::Variable::width().
{ for (int j=0; j<input2->size(); j++) { int i = (int)input2->valuedata[j]; input1->gradientdata[i*width()+j] += gradientdata[j]; } }
void PLearn::IndexAtPositionVariable::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::BinaryVariable.
Definition at line 68 of file IndexAtPositionVariable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::IndexAtPositionVariable::build_ | ( | ) | [protected] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 75 of file IndexAtPositionVariable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLERROR, and width_.
Referenced by build(), and IndexAtPositionVariable().
{ if (input1 && input2) { if(!input1->isVec() || !input2->isVec()) PLERROR("In IndexAtPositionVariable: input1 or input2 must be a vector var"); if(input1->size() != input2->size() || input1->size() != width_) PLERROR("In IndexAtPositionVariable: input1 and input2 should be of same size"); } }
string PLearn::IndexAtPositionVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file IndexAtPositionVariable.cc.
void PLearn::IndexAtPositionVariable::declareOptions | ( | OptionList & | ol | ) | [static] |
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::BinaryVariable.
Definition at line 86 of file IndexAtPositionVariable.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::BinaryVariable::declareOptions(), length_, and width_.
{ declareOption(ol, "length_", &IndexAtPositionVariable::length_, OptionBase::buildoption, ""); declareOption(ol, "width_", &IndexAtPositionVariable::width_, OptionBase::buildoption, ""); inherited::declareOptions(ol); }
static const PPath& PLearn::IndexAtPositionVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 64 of file IndexAtPositionVariable.h.
: void build_();
IndexAtPositionVariable * PLearn::IndexAtPositionVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 54 of file IndexAtPositionVariable.cc.
void PLearn::IndexAtPositionVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 97 of file IndexAtPositionVariable.cc.
References PLearn::TVec< T >::clear(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, j, PLearn::Variable::value, PLearn::Variable::valuedata, and PLearn::Variable::width().
{ value.clear(); for (int j=0; j<input2->size(); j++) { int i = (int)input2->valuedata[j]; valuedata[i*width()+j] = input1->valuedata[j]; } }
OptionList & PLearn::IndexAtPositionVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file IndexAtPositionVariable.cc.
OptionMap & PLearn::IndexAtPositionVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file IndexAtPositionVariable.cc.
RemoteMethodMap & PLearn::IndexAtPositionVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 54 of file IndexAtPositionVariable.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 93 of file IndexAtPositionVariable.cc.
void PLearn::IndexAtPositionVariable::rfprop | ( | ) | [virtual] |
Reimplemented from PLearn::Variable.
Definition at line 124 of file IndexAtPositionVariable.cc.
References PLERROR.
{ /* if (rValue.length()==0) resizeRValue(); rValue.clear(); if (input2->isScalar()) // input2 is a scalar (interpreted as a k) { int k = (int)input2->valuedata[0]; rvaluedata[k] = input1->rvaluedata[0]; } else // input2 has 2 Indexs (interpreted as (i,j) coordinates) { int i = (int)input2->valuedata[0]; int j = (int)input2->valuedata[1]; rvaluedata[i*width()+j] = input1->rvaluedata[0]; }*/ PLERROR("IndexAtPositionVariable::rfprop() not implemented."); }
void PLearn::IndexAtPositionVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 118 of file IndexAtPositionVariable.cc.
References PLearn::Variable::g, PLearn::BinaryVariable::input1, and PLearn::BinaryVariable::input2.
Reimplemented from PLearn::BinaryVariable.
Definition at line 64 of file IndexAtPositionVariable.h.
int PLearn::IndexAtPositionVariable::length_ [protected] |
Definition at line 57 of file IndexAtPositionVariable.h.
Referenced by declareOptions(), and recomputeSize().
int PLearn::IndexAtPositionVariable::width_ [protected] |
Definition at line 57 of file IndexAtPositionVariable.h.
Referenced by build_(), declareOptions(), and recomputeSize().