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

#include <WeightedSumSquareVariable.h>

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

List of all members.

Public Member Functions

 WeightedSumSquareVariable ()
 Default constructor for persistence.
 WeightedSumSquareVariable (Variable *input, Variable *weights)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual WeightedSumSquareVariabledeepCopy (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 ()
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_ ()
 WeightedSumSquareVariable.
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 56 of file WeightedSumSquareVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 58 of file WeightedSumSquareVariable.h.


Constructor & Destructor Documentation

PLearn::WeightedSumSquareVariable::WeightedSumSquareVariable ( ) [inline]

Default constructor for persistence.

Definition at line 62 of file WeightedSumSquareVariable.h.

{}
PLearn::WeightedSumSquareVariable::WeightedSumSquareVariable ( Variable input,
Variable weights 
)

Definition at line 55 of file WeightedSumSquareVariable.cc.

References build_().

    : inherited(input,weights,1,1)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

WeightedSumSquareVariable.

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Implements PLearn::Variable.

Definition at line 94 of file WeightedSumSquareVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and n.

{
    int n=input1->nelems();
    for(int i=0; i<n; i++)
    {
        input1->gradientdata[i]+= 2.0 * input1->valuedata[i] * input2->valuedata[i] * *gradientdata;
        input2->gradientdata[i]+= input1->valuedata[i] * input1->valuedata[i] * *gradientdata;
    }
}
void PLearn::WeightedSumSquareVariable::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 WeightedSumSquareVariable.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 69 of file WeightedSumSquareVariable.cc.

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

Referenced by build(), and WeightedSumSquareVariable().

{
    if (input1 && input2) {
        // input1 and input2 are (respectively) input and weights from constructor
        if (input1->nelems() != input2->nelems())
            PLERROR("In WeightedSumSquareVariable: input and weights must be the same size;"
                    " input->nelems()=%d weights->nelems()=&d.",
                    input1->nelems(), input2->nelems());
    }
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file WeightedSumSquareVariable.h.

:
    void build_();
WeightedSumSquareVariable * PLearn::WeightedSumSquareVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 85 of file WeightedSumSquareVariable.cc.

References i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, n, and PLearn::Variable::valuedata.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file WeightedSumSquareVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file WeightedSumSquareVariable.cc.

void PLearn::WeightedSumSquareVariable::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 81 of file WeightedSumSquareVariable.cc.

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

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

Reimplemented from PLearn::Variable.

Definition at line 105 of file WeightedSumSquareVariable.cc.

References PLearn::Variable::g, PLearn::BinaryVariable::input1, and PLearn::BinaryVariable::input2.

{
    input1->accg(2.0 * (g*input1*input2));
    input2->accg(g*input1*input1);
}

Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 65 of file WeightedSumSquareVariable.h.


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