PLearn 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types
PLearn::MulticlassLossVariable Class Reference

cost = sum_i {cost_i}, with cost_i = 1 if (target_i == 1 && output_i < 1/2) cost_i = 1 if (target_i == 0 && output_i > 1/2) cost_i = 0 otherwise More...

#include <MulticlassLossVariable.h>

Inheritance diagram for PLearn::MulticlassLossVariable:
Inheritance graph
[legend]
Collaboration diagram for PLearn::MulticlassLossVariable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MulticlassLossVariable ()
 Default constructor for persistence.
 MulticlassLossVariable (Variable *netout, Variable *target)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual MulticlassLossVariabledeepCopy (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_ ()
 MulticlassLossVariable.
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 This does the actual building.

Private Types

typedef BinaryVariable inherited

Detailed Description

cost = sum_i {cost_i}, with cost_i = 1 if (target_i == 1 && output_i < 1/2) cost_i = 1 if (target_i == 0 && output_i > 1/2) cost_i = 0 otherwise

Definition at line 57 of file MulticlassLossVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 59 of file MulticlassLossVariable.h.


Constructor & Destructor Documentation

PLearn::MulticlassLossVariable::MulticlassLossVariable ( ) [inline]

Default constructor for persistence.

Definition at line 63 of file MulticlassLossVariable.h.

{}
PLearn::MulticlassLossVariable::MulticlassLossVariable ( Variable netout,
Variable target 
)

Definition at line 55 of file MulticlassLossVariable.cc.

References build_().

    : inherited(netout,target,1,1)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

string PLearn::MulticlassLossVariable::_classname_ ( ) [static]

MulticlassLossVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MulticlassLossVariable.cc.

OptionList & PLearn::MulticlassLossVariable::_getOptionList_ ( ) [static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MulticlassLossVariable.cc.

RemoteMethodMap & PLearn::MulticlassLossVariable::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MulticlassLossVariable.cc.

bool PLearn::MulticlassLossVariable::_isa_ ( const Object o) [static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MulticlassLossVariable.cc.

Object * PLearn::MulticlassLossVariable::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 53 of file MulticlassLossVariable.cc.

StaticInitializer MulticlassLossVariable::_static_initializer_ & PLearn::MulticlassLossVariable::_static_initialize_ ( ) [static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MulticlassLossVariable.cc.

virtual void PLearn::MulticlassLossVariable::bprop ( ) [inline, virtual]

can't bprop through a hard classification error...

Implements PLearn::Variable.

Definition at line 73 of file MulticlassLossVariable.h.

{}
void PLearn::MulticlassLossVariable::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 MulticlassLossVariable.cc.

References PLearn::BinaryVariable::build(), and build_().

Here is the call graph for this function:

void PLearn::MulticlassLossVariable::build_ ( ) [protected]

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 69 of file MulticlassLossVariable.cc.

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLERROR.

Referenced by build(), and MulticlassLossVariable().

{
    if (input1 && input2) {
        // input1 and input2 are (respectively) netout and target from constructor
        if(input1->size() != input2->size())
            PLERROR("In MulticlassLossVariable: netout and target must the same size");
    }
}

Here is the caller graph for this function:

string PLearn::MulticlassLossVariable::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file MulticlassLossVariable.cc.

static const PPath& PLearn::MulticlassLossVariable::declaringFile ( ) [inline, static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 66 of file MulticlassLossVariable.h.

{}
MulticlassLossVariable * PLearn::MulticlassLossVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MulticlassLossVariable.cc.

void PLearn::MulticlassLossVariable::fprop ( ) [virtual]

compute output given input

Implements PLearn::Variable.

Definition at line 83 of file MulticlassLossVariable.cc.

References PLearn::fast_exact_is_equal(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLASSERT, and PLearn::Variable::valuedata.

{
    real cost = 0.0;
    for (int i=0; i<input1->size(); i++)
    {
        real output = input1->valuedata[i];
        real target = input2->valuedata[i];
        PLASSERT( fast_exact_is_equal(target, 1) ||
                fast_exact_is_equal(target, 0) );
        cost += fast_exact_is_equal(target, 1) ? output<0.5 : output>0.5;
    }
    valuedata[0] = cost;
}

Here is the call graph for this function:

OptionList & PLearn::MulticlassLossVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file MulticlassLossVariable.cc.

OptionMap & PLearn::MulticlassLossVariable::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file MulticlassLossVariable.cc.

RemoteMethodMap & PLearn::MulticlassLossVariable::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file MulticlassLossVariable.cc.

void PLearn::MulticlassLossVariable::recomputeSize ( int l,
int w 
) const [virtual]

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 79 of file MulticlassLossVariable.cc.

{ l=1, w=1; }

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 66 of file MulticlassLossVariable.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines