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

#include <MaxVariable.h>

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

List of all members.

Public Member Functions

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

Definition at line 53 of file MaxVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file MaxVariable.h.


Constructor & Destructor Documentation

PLearn::MaxVariable::MaxVariable ( ) [inline]

Default constructor for persistence.

Definition at line 59 of file MaxVariable.h.

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

Definition at line 63 of file MaxVariable.cc.

    : inherited(input, 1, 1)
{}

Member Function Documentation

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

MaxVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

void PLearn::MaxVariable::bprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 83 of file MaxVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, and PLearn::Variable::valuedata.

{
    real maxval = valuedata[0];
    for(int i=0; i<input->nelems(); i++)
    {
        if(input->valuedata[i]==maxval)
            input->gradientdata[i] += gradientdata[0];
    }
}
string PLearn::MaxVariable::classname ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file MaxVariable.h.

{ return new MaxVariable(v); }
MaxVariable * PLearn::MaxVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 70 of file MaxVariable.cc.

References i, PLearn::UnaryVariable::input, and PLearn::Variable::valuedata.

{
    real maxval = input->valuedata[0];
    for(int i=1; i<input->nelems(); i++)
    {
        real val = input->valuedata[i];
        if(val>maxval)
            maxval = val;
    }
    valuedata[0] = maxval;
}
OptionList & PLearn::MaxVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file MaxVariable.cc.

void PLearn::MaxVariable::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 67 of file MaxVariable.cc.

{ l=1; w=1; }
void PLearn::MaxVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 94 of file MaxVariable.cc.

References PLearn::argmax(), PLearn::Variable::g, PLearn::UnaryVariable::input, PLearn::Var::length(), and PLearn::Var::width().

{
    input->accg(new ElementAtPositionVariable(g, argmax(input), input->length(), input->width()));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file MaxVariable.h.


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