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

#include <SumSquareVariable.h>

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

List of all members.

Public Member Functions

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


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SumSquareVariable.h.


Constructor & Destructor Documentation

PLearn::SumSquareVariable::SumSquareVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file SumSquareVariable.h.

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

Definition at line 57 of file SumSquareVariable.cc.

    : inherited(input, 1, 1) {}

Member Function Documentation

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

SumSquareVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 77 of file SumSquareVariable.cc.

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

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SumSquareVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file SumSquareVariable.cc.

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

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file SumSquareVariable.cc.

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

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

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

Reimplemented from PLearn::Variable.

Definition at line 85 of file SumSquareVariable.cc.

References PLearn::Variable::g, and PLearn::UnaryVariable::input.

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

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SumSquareVariable.h.


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