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

#include <ArgmaxVariable.h>

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

List of all members.

Public Member Functions

 ArgmaxVariable ()
 Default constructor for persistence.
 ArgmaxVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ArgmaxVariabledeepCopy (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 PPathdeclaringFile ()

Static Public Attributes

static StaticInitializer _static_initializer_

Private Types

typedef UnaryVariable inherited

Detailed Description

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.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file ArgmaxVariable.h.


Constructor & Destructor Documentation

PLearn::ArgmaxVariable::ArgmaxVariable ( ) [inline]

Default constructor for persistence.

Definition at line 62 of file ArgmaxVariable.h.

{}
PLearn::ArgmaxVariable::ArgmaxVariable ( Variable input)

Definition at line 55 of file ArgmaxVariable.cc.

    : inherited(input, input->isVec()?1:2, 1)
{}

Member Function Documentation

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

ArgmaxVariable.

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.

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

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;
    }
}

Here is the call graph for this function:

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.

void PLearn::ArgmaxVariable::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 60 of file ArgmaxVariable.cc.

References PLearn::UnaryVariable::input.

{
    if (input)
        l = input->isVec() ? 1 : 2;
    w = 1;
}
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.

{}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 65 of file ArgmaxVariable.h.


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