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

#include <MiniBatchClassificationLossVariable.h>

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

List of all members.

Public Member Functions

 MiniBatchClassificationLossVariable ()
 Default constructor for persistence.
 MiniBatchClassificationLossVariable (Variable *netout, Variable *classnum)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
MiniBatchClassificationLossVariable
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...
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_ ()
 MiniBatchClassificationLossVariable.
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

Definition at line 52 of file MiniBatchClassificationLossVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 54 of file MiniBatchClassificationLossVariable.h.


Constructor & Destructor Documentation

PLearn::MiniBatchClassificationLossVariable::MiniBatchClassificationLossVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file MiniBatchClassificationLossVariable.h.

{}
PLearn::MiniBatchClassificationLossVariable::MiniBatchClassificationLossVariable ( Variable netout,
Variable classnum 
)

Definition at line 55 of file MiniBatchClassificationLossVariable.cc.

References build_().

    : inherited(netout,classnum,classnum->length(),classnum->width())
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

string PLearn::MiniBatchClassificationLossVariable::_classname_ ( ) [static]
OptionList & PLearn::MiniBatchClassificationLossVariable::_getOptionList_ ( ) [static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

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

Implements PLearn::Variable.

Definition at line 68 of file MiniBatchClassificationLossVariable.h.

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

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 69 of file MiniBatchClassificationLossVariable.cc.

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

Referenced by build(), and MiniBatchClassificationLossVariable().

{
    // input2 is classnum from constructor
    if(input2 && !input2->isVec())
        PLERROR("In MiniBatchClassificationLossVariable: classnum must be a vector variable representing the indexs of netout (typically class numbers)");
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 61 of file MiniBatchClassificationLossVariable.h.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 86 of file MiniBatchClassificationLossVariable.cc.

References PLearn::argmax(), PLearn::Var::column(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::Var::length(), n, PLERROR, PLearn::Var::row(), PLearn::Variable::valuedata, and PLearn::Var::width().

{
    int n = input2->size();
    if(input1->length()==n)
        for (int i=0; i<n; i++)
        {
            int topscorepos = argmax(input1->matValue.row(i));
            int num = int(input2->valuedata[i]);
            valuedata[i] = (topscorepos==num ?0 :1);
        }
    else if(input1->width()==n)
        for (int i=0; i<n; i++)
        {
            int topscorepos = argmax(input1->matValue.column(i));
            int num = int(input2->valuedata[i]);
            valuedata[i] = (topscorepos==num ?0 :1);
        }
    else PLERROR("In MiniBatchClassificationLossVariable: The length or width of netout doesn't equal to the size of classnum");
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file MiniBatchClassificationLossVariable.cc.

void PLearn::MiniBatchClassificationLossVariable::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 77 of file MiniBatchClassificationLossVariable.cc.

References PLearn::BinaryVariable::input2, PLearn::Var::length(), and PLearn::Var::width().

{
    if (input2) {
        l = input2->length();
        w = input2->width();
    } else
        l = w = 0;
}

Here is the call graph for this function:

void PLearn::MiniBatchClassificationLossVariable::symbolicBprop ( ) [virtual]

compute a piece of new Var graph that represents the symbolic derivative of this Var

Reimplemented from PLearn::Variable.

Definition at line 107 of file MiniBatchClassificationLossVariable.cc.

References PLERROR.

{
    PLERROR("MiniBatchClassificationLossVariable::symbolicBprop not implemented.");
}

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 61 of file MiniBatchClassificationLossVariable.h.


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