PLearn 0.1
|
#include <ArgmaxVariable.h>
Public Member Functions | |
ArgmaxVariable () | |
Default constructor for persistence. | |
ArgmaxVariable (Variable *input) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ArgmaxVariable * | 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 | |
Static Public Member Functions | |
static string | _classname_ () |
ArgmaxVariable. | |
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 |
This variable computes the index of the maximum value in the input It is a scalar variable if the input is a vector (single row or single column) Otherwise it is a single-column of length() 2 containing the (i,j) coordinate of the max
Definition at line 56 of file ArgmaxVariable.h.
typedef UnaryVariable PLearn::ArgmaxVariable::inherited [private] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 58 of file ArgmaxVariable.h.
PLearn::ArgmaxVariable::ArgmaxVariable | ( | ) | [inline] |
PLearn::ArgmaxVariable::ArgmaxVariable | ( | Variable * | input | ) |
Definition at line 55 of file ArgmaxVariable.cc.
string PLearn::ArgmaxVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
OptionList & PLearn::ArgmaxVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
RemoteMethodMap & PLearn::ArgmaxVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
Object * PLearn::ArgmaxVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
StaticInitializer ArgmaxVariable::_static_initializer_ & PLearn::ArgmaxVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
void PLearn::ArgmaxVariable::bprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 106 of file ArgmaxVariable.cc.
{}
string PLearn::ArgmaxVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
static const PPath& PLearn::ArgmaxVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 65 of file ArgmaxVariable.h.
{ return new ArgmaxVariable(v); }
ArgmaxVariable * PLearn::ArgmaxVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
void PLearn::ArgmaxVariable::fprop | ( | ) | [virtual] |
Nothing to do by default.
Reimplemented from PLearn::UnaryVariable.
Definition at line 67 of file ArgmaxVariable.cc.
References PLearn::argmax(), i, PLearn::UnaryVariable::input, j, PLearn::Var::length(), PLearn::Variable::valuedata, and PLearn::Var::width().
{ real maxval = input->valuedata[0]; if (input->isVec()) { int argmax = 0; for(int i=1; i<input->nelems(); i++) { real val = input->valuedata[i]; if(val>maxval) { maxval = val; argmax = i; } } valuedata[0] = argmax; } else { int k = 0; int argmax_i = 0; int argmax_j = 0; for(int i=0; i<input->length(); i++) for(int j=0; j<input->width(); j++, k++) { real val = input->valuedata[k]; if(val>maxval) { maxval = val; argmax_i = i; argmax_j = j; } } valuedata[0] = argmax_i; valuedata[1] = argmax_j; } }
OptionList & PLearn::ArgmaxVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
OptionMap & PLearn::ArgmaxVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.cc.
RemoteMethodMap & PLearn::ArgmaxVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::UnaryVariable.
Definition at line 53 of file ArgmaxVariable.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 60 of file ArgmaxVariable.cc.
References PLearn::UnaryVariable::input.
void PLearn::ArgmaxVariable::symbolicBprop | ( | ) | [virtual] |
compute a piece of new Var graph that represents the symbolic derivative of this Var
Reimplemented from PLearn::Variable.
Definition at line 108 of file ArgmaxVariable.cc.
{}
Reimplemented from PLearn::UnaryVariable.
Definition at line 65 of file ArgmaxVariable.h.