PLearn 0.1
|
Indicator(classnum==argmax(netout)) More...
#include <ClassificationLossVariable.h>
Public Member Functions | |
ClassificationLossVariable () | |
Default constructor for persistence. | |
ClassificationLossVariable (Variable *netout, Variable *classnum) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ClassificationLossVariable * | 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 () |
can't bprop through a hard classification error... | |
Static Public Member Functions | |
static string | _classname_ () |
ClassificationLossVariable. | |
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 |
Indicator(classnum==argmax(netout))
Definition at line 55 of file ClassificationLossVariable.h.
typedef BinaryVariable PLearn::ClassificationLossVariable::inherited [private] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 57 of file ClassificationLossVariable.h.
PLearn::ClassificationLossVariable::ClassificationLossVariable | ( | ) | [inline] |
PLearn::ClassificationLossVariable::ClassificationLossVariable | ( | Variable * | netout, |
Variable * | classnum | ||
) |
Definition at line 55 of file ClassificationLossVariable.cc.
References build_().
string PLearn::ClassificationLossVariable::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ClassificationLossVariable.cc.
OptionList & PLearn::ClassificationLossVariable::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ClassificationLossVariable.cc.
RemoteMethodMap & PLearn::ClassificationLossVariable::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ClassificationLossVariable.cc.
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ClassificationLossVariable.cc.
Object * PLearn::ClassificationLossVariable::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ClassificationLossVariable.cc.
StaticInitializer ClassificationLossVariable::_static_initializer_ & PLearn::ClassificationLossVariable::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ClassificationLossVariable.cc.
virtual void PLearn::ClassificationLossVariable::bprop | ( | ) | [inline, virtual] |
can't bprop through a hard classification error...
Implements PLearn::Variable.
Definition at line 71 of file ClassificationLossVariable.h.
{}
void PLearn::ClassificationLossVariable::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 62 of file ClassificationLossVariable.cc.
References PLearn::BinaryVariable::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ClassificationLossVariable::build_ | ( | ) | [protected] |
This does the actual building.
Reimplemented from PLearn::BinaryVariable.
Definition at line 69 of file ClassificationLossVariable.cc.
References PLearn::BinaryVariable::input2, and PLERROR.
Referenced by build(), and ClassificationLossVariable().
{ // input2 is classnum from constructor if (input2 && !input2->isScalar()) PLERROR("In ClassificationLossVariable: classnum must be a scalar variable representing an index of netout (typically a class number)"); }
string PLearn::ClassificationLossVariable::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ClassificationLossVariable.cc.
static const PPath& PLearn::ClassificationLossVariable::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 64 of file ClassificationLossVariable.h.
{}
ClassificationLossVariable * PLearn::ClassificationLossVariable::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::BinaryVariable.
Definition at line 53 of file ClassificationLossVariable.cc.
void PLearn::ClassificationLossVariable::fprop | ( | ) | [virtual] |
compute output given input
Implements PLearn::Variable.
Definition at line 80 of file ClassificationLossVariable.cc.
References PLearn::argmax(), PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Variable::valuedata.
{ int topscorepos = argmax(input1->value); int classnum = int(input2->valuedata[0]); valuedata[0] = (topscorepos==classnum ?0 :1); }
OptionList & PLearn::ClassificationLossVariable::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ClassificationLossVariable.cc.
OptionMap & PLearn::ClassificationLossVariable::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ClassificationLossVariable.cc.
RemoteMethodMap & PLearn::ClassificationLossVariable::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 53 of file ClassificationLossVariable.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 76 of file ClassificationLossVariable.cc.
{ l=1, w=1; }
Reimplemented from PLearn::BinaryVariable.
Definition at line 64 of file ClassificationLossVariable.h.