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

#include <LogVariable.h>

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

List of all members.

Public Member Functions

 LogVariable ()
 Default constructor for persistence.
 LogVariable (Variable *input)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual LogVariabledeepCopy (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
virtual void rfprop ()

Static Public Member Functions

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


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file LogVariable.h.


Constructor & Destructor Documentation

PLearn::LogVariable::LogVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file LogVariable.h.

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

Definition at line 60 of file LogVariable.cc.

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

Member Function Documentation

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

LogVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 103 of file LogVariable.cc.

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

{
    PLASSERT( input && input->gradientdata == input->gradient.data() );
    for(int i=0; i<nelems(); i++)
        if (input->valuedata[i]>0)
            input->gradientdata[i] += gradientdata[i]/input->valuedata[i];
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file LogVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 79 of file LogVariable.cc.

References PLearn::displayVarGraph(), PLearn::endl(), i, PLearn::UnaryVariable::input, PLearn::Variable::nelems(), PLASSERT, PLERROR, PLearn::pout, PLearn::safeflog(), and PLearn::Variable::valuedata.

{
    PLASSERT( input && nelems() == input->nelems() );
    for(int i=0; i<nelems(); i++)
    {
        valuedata[i] = safeflog(input->valuedata[i]);
#ifdef BOUNDCHECK
        real val = valuedata[i];
        real ival = input->valuedata[i];
        if (!finite(val) && finite(ival))
        {
            //PLWARNING("LogVariable::fprop something is wrong");
            pout << "inputdata[i]= " << input->valuedata[i] << endl;
            pout << "valuedata[i]= " << valuedata[i] << endl;
            displayVarGraph(this, true, 250);
            PLERROR("LogVariable::fprop Something is wrong");
        }
#endif
    }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 58 of file LogVariable.cc.

void PLearn::LogVariable::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 67 of file LogVariable.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::LogVariable::rfprop ( ) [virtual]

Reimplemented from PLearn::Variable.

Definition at line 123 of file LogVariable.cc.

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

{
    if (rValue.length()==0) resizeRValue();
    for(int i=0; i<nelems(); i++)
        rvaluedata[i] = input->rvaluedata[i] / input->valuedata[i];
}

Here is the call graph for this function:

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

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

Reimplemented from PLearn::Variable.

Definition at line 114 of file LogVariable.cc.

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

{
    input->accg(g / input);
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 61 of file LogVariable.h.


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