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

#include <SigmoidVariable.h>

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

List of all members.

Public Member Functions

 SigmoidVariable ()
 Default constructor for persistence.
 SigmoidVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual SigmoidVariabledeepCopy (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 bbprop ()
 compute an approximation to diag(d^2/dinput^2) given diag(d^2/doutput^2), with diag(d^2/dinput^2) ~=~ (doutput/dinput)' diag(d^2/doutput^2) (doutput/dinput) In particular: if 'C' depends on 'y' and 'y' depends on x ...
virtual void symbolicBprop ()
 compute a piece of new Var graph that represents the symbolic derivative of this Var
virtual void rfprop ()

Static Public Member Functions

static string _classname_ ()
 SigmoidVariable.
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 SigmoidVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.h.


Constructor & Destructor Documentation

PLearn::SigmoidVariable::SigmoidVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file SigmoidVariable.h.

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

Definition at line 56 of file SigmoidVariable.cc.

    : inherited(input, input->length(), input->width())
{}

Member Function Documentation

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

SigmoidVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

void PLearn::SigmoidVariable::bbprop ( ) [virtual]

compute an approximation to diag(d^2/dinput^2) given diag(d^2/doutput^2), with diag(d^2/dinput^2) ~=~ (doutput/dinput)' diag(d^2/doutput^2) (doutput/dinput) In particular: if 'C' depends on 'y' and 'y' depends on x ...

d^2C/dx^2 = d^2C/dy^2 * (dy/dx)^2 + dC/dy * d^2y/dx^2 (diaghessian) (gradient)

Reimplemented from PLearn::Variable.

Definition at line 93 of file SigmoidVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, PLearn::Var::length(), PLearn::Variable::nelems(), and PLearn::Variable::valuedata.

{
    if (input->diaghessian.length()==0)
        input->resizeDiagHessian();
    for(int i=0; i<nelems(); i++)
    {
        real yi = valuedata[i];
        real fprime = yi*(1-yi);
        input->gradientdata[i] += gradientdata[i] * fprime * fprime;
    }
}

Here is the call graph for this function:

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 79 of file SigmoidVariable.cc.

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

{
    int l = nelems();
    real* inputgradientptr = input->gradientdata;
    real* gradientptr = gradientdata;
    real* valueptr = valuedata;
    for(int i=0; i<l; i++)
    {
        real val = *valueptr++;
        *inputgradientptr++ += *gradientptr++ * val*(1.0-val);
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SigmoidVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 69 of file SigmoidVariable.cc.

References i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), PLearn::sigmoid(), and PLearn::Variable::valuedata.

{
    int l = nelems();
    real* valueptr = valuedata;
    real* inputvalueptr = input->valuedata;
    for(int i=0; i<l; i++)
        *valueptr++ = sigmoid(*inputvalueptr++);
}

Here is the call graph for this function:

OptionList & PLearn::SigmoidVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file SigmoidVariable.cc.

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

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

{
    if (input) {
        l = input->length();
        w = input->width();
    } else
        l = w = 0;
}

Here is the call graph for this function:

void PLearn::SigmoidVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 114 of file SigmoidVariable.cc.

References i, PLearn::UnaryVariable::input, PLearn::TVec< T >::length(), PLearn::Variable::nelems(), PLearn::UnaryVariable::resizeRValue(), PLearn::Variable::rValue, PLearn::Variable::rvaluedata, and PLearn::Variable::valuedata.

{
    if (rValue.length()==0) resizeRValue();
    int l = nelems();
    real* inputptr = input->rvaluedata;
    real* inputvalueptr = valuedata;
    real* ptr = rvaluedata;
    for(int i=0; i<l; i++)
    {
        real val = *inputvalueptr++;
        *ptr++ = *inputptr++ * val * (1.0 - val);
    }
}

Here is the call graph for this function:

void PLearn::SigmoidVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 106 of file SigmoidVariable.cc.

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

{
    Var v(this);
    input->accg(g*v*(1. - v));
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file SigmoidVariable.h.


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