PLearn 0.1
|
#include <Min2Variable.h>
Public Member Functions | |
Min2Variable () | |
Default constructor for persistence. | |
Min2Variable (Variable *input1, Variable *input2) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual Min2Variable * | 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 | |
Static Public Member Functions | |
static string | _classname_ () |
Min2Variable. | |
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_ |
Protected Member Functions | |
void | build_ () |
This does the actual building. | |
Private Types | |
typedef BinaryVariable | inherited |
elementwise min over 2 elements: min(v1,v2)[i] = min(v1[i],v2[i]) with same dimensions as the input vectors (both must have same length())
Definition at line 56 of file Min2Variable.h.
typedef BinaryVariable PLearn::Min2Variable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 58 of file Min2Variable.h.
PLearn::Min2Variable::Min2Variable | ( | ) | [inline] |
string PLearn::Min2Variable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file Min2Variable.cc.
OptionList & PLearn::Min2Variable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file Min2Variable.cc.
RemoteMethodMap & PLearn::Min2Variable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file Min2Variable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file Min2Variable.cc.
Object * PLearn::Min2Variable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 62 of file Min2Variable.cc.
StaticInitializer Min2Variable::_static_initializer_ & PLearn::Min2Variable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file Min2Variable.cc.
void PLearn::Min2Variable::bprop | ( | ) | [virtual] |
Implements PLearn::Variable.
Definition at line 109 of file Min2Variable.cc.
References PLearn::TVec< T >::data(), grad, PLearn::Variable::gradient, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), n, and PLASSERT.
{ PLASSERT( input1 && input2 ); int n=input1->value.length(); real* v1=input1->value.data(); real* v2=input2->value.data(); real* grad1=input1->gradient.data(); real* grad2=input2->gradient.data(); real* grad=gradient.data(); for (int i=0;i<n;i++) { if (v1[i]<v2[i]) grad1[i] += grad[i]; if (v2[i]<v1[i]) grad2[i] += grad[i]; } }
void PLearn::Min2Variable::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 72 of file Min2Variable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::Min2Variable::build_ | ( | ) | [protected] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 79 of file Min2Variable.cc.
References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), PLERROR, and PLearn::Var::width().
Referenced by build(), and Min2Variable().
{ if (input1 && input2) { if (input1->length() != input2->length() || input1->width() != input2->width()) PLERROR("IN Min2Variable input1 and input2 must have the same size"); } }
string PLearn::Min2Variable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 62 of file Min2Variable.cc.
static const PPath& PLearn::Min2Variable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 65 of file Min2Variable.h.
: void build_();
Min2Variable * PLearn::Min2Variable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 62 of file Min2Variable.cc.
void PLearn::Min2Variable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 97 of file Min2Variable.cc.
References PLearn::TVec< T >::data(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), min, n, PLASSERT, and PLearn::Variable::value.
{ PLASSERT( input1 && input2 ); int n=input1->value.length(); real* v1=input1->value.data(); real* v2=input2->value.data(); real* v=value.data(); for (int i=0;i<n;i++) v[i] = std::min(v1[i],v2[i]); }
OptionList & PLearn::Min2Variable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 62 of file Min2Variable.cc.
OptionMap & PLearn::Min2Variable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 62 of file Min2Variable.cc.
RemoteMethodMap & PLearn::Min2Variable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 62 of file Min2Variable.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 88 of file Min2Variable.cc.
References PLearn::BinaryVariable::input1, PLearn::Var::length(), and PLearn::Var::width().
void PLearn::Min2Variable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 128 of file Min2Variable.cc.
References PLearn::Variable::g, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLASSERT.
Reimplemented from PLearn::BinaryVariable.
Definition at line 65 of file Min2Variable.h.