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

returns the elementwise x*log(x) in a (hopefully!) numerically stable way This can be used to compute the Entropy for instance More...

#include <PLogPVariable.h>

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

List of all members.

Public Member Functions

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

returns the elementwise x*log(x) in a (hopefully!) numerically stable way This can be used to compute the Entropy for instance

Definition at line 54 of file PLogPVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 56 of file PLogPVariable.h.


Constructor & Destructor Documentation

PLearn::PLogPVariable::PLogPVariable ( ) [inline]

Default constructor for persistence.

Definition at line 60 of file PLogPVariable.h.

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

Definition at line 57 of file PLogPVariable.cc.

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

Member Function Documentation

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

PLogPVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 83 of file PLogPVariable.cc.

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

{
    for(int i=0; i<nelems(); i++)
    {
        real p = input->valuedata[i];
        if(p<1e-10)
            p = 1e-10;
        input->gradientdata[i] += gradientdata[i]*(1.0+safeflog(p));
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file PLogPVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 71 of file PLogPVariable.cc.

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

{
    for(int i=0; i<nelems(); i++)
    {
        real p = input->valuedata[i];
        if(p<1e-10)
            p = 1e-10;
        valuedata[i] = p*safeflog(p);
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 55 of file PLogPVariable.cc.

void PLearn::PLogPVariable::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 62 of file PLogPVariable.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::PLogPVariable::symbolicBprop ( ) [virtual]

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

Reimplemented from PLearn::Variable.

Definition at line 95 of file PLogPVariable.cc.

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

{
    input->accg(g * (1.+log(input)));
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file PLogPVariable.h.


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