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

#include <TanhVariable.h>

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

List of all members.

Public Member Functions

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

* Simple unary transforms... *

Definition at line 54 of file TanhVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 56 of file TanhVariable.h.


Constructor & Destructor Documentation

PLearn::TanhVariable::TanhVariable ( ) [inline]

Default constructor for persistence.

Definition at line 60 of file TanhVariable.h.

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

Definition at line 56 of file TanhVariable.cc.

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

Member Function Documentation

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

TanhVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

void PLearn::TanhVariable::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 90 of file TanhVariable.cc.

References PLearn::Variable::diaghessiandata, 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=(1-yi*yi);
        input->diaghessiandata[i] += diaghessiandata[i] * fprime * fprime;
    }
}

Here is the call graph for this function:

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 79 of file TanhVariable.cc.

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

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file TanhVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 69 of file TanhVariable.cc.

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

{
    int l = nelems();
    real* inputptr = input->valuedata;
    real* ptr = valuedata;
    for(int i=0; i<l; i++)
        *ptr++ = tanh(*inputptr++);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file TanhVariable.cc.

void PLearn::TanhVariable::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 TanhVariable.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::TanhVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 111 of file TanhVariable.cc.

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

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

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 103 of file TanhVariable.cc.

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

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

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file TanhVariable.h.


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