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

#include <NegLogPoissonVariable.h>

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

List of all members.

Public Member Functions

 NegLogPoissonVariable ()
 Default constructor for persistence.
 NegLogPoissonVariable (VarArray &the_varray)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual NegLogPoissonVariabledeepCopy (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 ()

Static Public Member Functions

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

Public Attributes

bool scaled_targets

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.

Protected Attributes

bool has_weight

Private Types

typedef NaryVariable inherited

Detailed Description

Definition at line 52 of file NegLogPoissonVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 54 of file NegLogPoissonVariable.h.


Constructor & Destructor Documentation

PLearn::NegLogPoissonVariable::NegLogPoissonVariable ( ) [inline]

Default constructor for persistence.

Definition at line 58 of file NegLogPoissonVariable.h.

{}
PLearn::NegLogPoissonVariable::NegLogPoissonVariable ( VarArray the_varray)

Definition at line 67 of file NegLogPoissonVariable.cc.

References build_().

    : inherited(the_varray, 1, 1)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

NegLogPoissonVariable.

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Implements PLearn::Variable.

Definition at line 117 of file NegLogPoissonVariable.cc.

References PLearn::exp(), PLearn::Variable::gradient, i, PLearn::TVec< T >::size(), PLearn::Variable::valuedata, and PLearn::NaryVariable::varray.

{
    real gr = gradient[0];
    for (int i=0; i<varray[0]->size(); i++)
    {
        real output = varray[0]->valuedata[i];
        real target = varray[1]->valuedata[i];
        real weight = 1;
        if (varray.size()>2)
            weight = varray[2]->valuedata[i];

        if (weight > 0)
            varray[0]->gradientdata[i] += gr * ( exp(output) - target / weight);
//        varray[0]->gradientdata[i] += gr* ( exp(output) * weight - target);
    }
}

Here is the call graph for this function:

void PLearn::NegLogPoissonVariable::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::NaryVariable.

Definition at line 74 of file NegLogPoissonVariable.cc.

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

Here is the call graph for this function:

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

Object-specific post-constructor.

This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build() method, and possibly the public virtual read method (which calls its parent's read). build_() can assume that its parent's build_() has already been called.

Reimplemented from PLearn::NaryVariable.

Definition at line 81 of file NegLogPoissonVariable.cc.

References PLERROR, PLearn::TVec< T >::size(), PLearn::Variable::size(), and PLearn::NaryVariable::varray.

Referenced by build(), and NegLogPoissonVariable().

{
    if (varray[0] && varray[1] && (varray[0]->size() != varray[1]->size()))
        PLERROR("In NegLogPoissonVariable: netout and target must have the same size");
    if (varray.size()>2 && varray[0] && varray[2] && (varray[0]->size() != varray[2]->size()))
        PLERROR("In NegLogPoissonVariable: netout and weight must have the same size");
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 61 of file NegLogPoissonVariable.h.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 92 of file NegLogPoissonVariable.cc.

References PLearn::exp(), i, PLearn::is_missing(), PLearn::max(), PLearn::pl_gammln(), pl_log, PLERROR, PLearn::TVec< T >::size(), PLearn::Variable::valuedata, and PLearn::NaryVariable::varray.

{
    real cost = 0.0;
    for (int i=0; i<varray[0]->size(); i++)
    {
        real output = varray[0]->valuedata[i];
        real target = varray[1]->valuedata[i];
        real weight = 1;
        if (varray.size()>2)
            weight = varray[2]->valuedata[i];

        static real EPSILON = 1e-8;          // Regularization
        real log_fact_target = pl_gammln(max(target, EPSILON)+1);
//        cost += exp(output) * weight - (output + pl_log(weight) ) * target + log_fact_target;

        if (weight > 0)
            cost += exp(output) - (output + pl_log(weight)) * target / weight +
                    log_fact_target / weight;
    }
    if (is_missing(cost))
        PLERROR("NegLogPoissonVariable::fprop: encountered NaN cost");
    
    valuedata[0] = cost;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 57 of file NegLogPoissonVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 57 of file NegLogPoissonVariable.cc.

void PLearn::NegLogPoissonVariable::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 89 of file NegLogPoissonVariable.cc.

{ l=1, w=1; }

Member Data Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 61 of file NegLogPoissonVariable.h.

Definition at line 78 of file NegLogPoissonVariable.h.

Definition at line 74 of file NegLogPoissonVariable.h.


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