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

#include <SumAbsVariable.h>

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

List of all members.

Public Member Functions

 SumAbsVariable ()
 Default constructor for persistence.
 SumAbsVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SumAbsVariabledeepCopy (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_ ()
 SumAbsVariable.
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 52 of file SumAbsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SumAbsVariable.h.


Constructor & Destructor Documentation

PLearn::SumAbsVariable::SumAbsVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file SumAbsVariable.h.

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

Definition at line 64 of file SumAbsVariable.cc.

    : inherited(input, 1, 1) {}

Member Function Documentation

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

SumAbsVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 79 of file SumAbsVariable.cc.

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

{
    int n=input->nelems();
    for(int i=0; i<n; i++)
        if (input->valuedata[i]>0)
            input->gradientdata[i]+= *gradientdata;
        else if (input->valuedata[i]<0)
            input->gradientdata[i]-= *gradientdata;
}
string PLearn::SumAbsVariable::classname ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SumAbsVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 70 of file SumAbsVariable.cc.

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

{
    int n=input->nelems();
    *valuedata= 0;
    for(int i=0; i<n; i++)
        *valuedata+= fabs(input->valuedata[i]);
}
OptionList & PLearn::SumAbsVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 62 of file SumAbsVariable.cc.

void PLearn::SumAbsVariable::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 SumAbsVariable.cc.

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

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

Reimplemented from PLearn::Variable.

Definition at line 90 of file SumAbsVariable.cc.

References PLearn::abs(), PLearn::Variable::g, and PLearn::UnaryVariable::input.

{
    input->accg(g*abs(input));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SumAbsVariable.h.


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