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

#include <UnaryHardSlopeVariable.h>

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

List of all members.

Public Member Functions

 UnaryHardSlopeVariable ()
 Default constructor for persistence.
 UnaryHardSlopeVariable (Variable *input, real l=-1, real r=1)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual UnaryHardSlopeVariabledeepCopy (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 ()
 Nothing to do by default.
virtual void bprop ()
 Nothing to do by default.

Static Public Member Functions

static string _classname_ ()
 UnaryHardSlopeVariable.
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 void declareOptions (OptionList &ol)
 Declare options (data fields) for the class.

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.

Protected Attributes

real left
real right
real inv_slope

Private Types

typedef UnaryVariable inherited

Detailed Description

* Simple unary transform with hard_slope function *

Definition at line 54 of file UnaryHardSlopeVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 56 of file UnaryHardSlopeVariable.h.


Constructor & Destructor Documentation

PLearn::UnaryHardSlopeVariable::UnaryHardSlopeVariable ( )

Default constructor for persistence.

Definition at line 56 of file UnaryHardSlopeVariable.cc.

    : left(0), right(0), inv_slope(0)
{ }
PLearn::UnaryHardSlopeVariable::UnaryHardSlopeVariable ( Variable input,
real  l = -1,
real  r = 1 
)

Definition at line 60 of file UnaryHardSlopeVariable.cc.

    : inherited(input, input->length(), input->width()) ,
      left(l), right(r), inv_slope(1.0/(r-l))
{}

Member Function Documentation

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

UnaryHardSlopeVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 106 of file UnaryHardSlopeVariable.cc.

References PLearn::Variable::gradientdata, i, PLearn::UnaryVariable::input, inv_slope, left, PLearn::Variable::nelems(), right, PLearn::Variable::valuedata, and x.

{
    int l = nelems();
    real* inputgradientptr = input->gradientdata;
    real* gradientptr = gradientdata;
    real* valueptr = valuedata;
    for(int i=0; i<l; i++)
    {
        real x = *valueptr++;
        if (x>left)
            if (x<right)
                *inputgradientptr++ += *gradientptr++ * inv_slope;
    }
}

Here is the call graph for this function:

void PLearn::UnaryHardSlopeVariable::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::UnaryVariable.

Definition at line 66 of file UnaryHardSlopeVariable.cc.

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

Here is the call graph for this function:

void PLearn::UnaryHardSlopeVariable::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::UnaryVariable.

Definition at line 73 of file UnaryHardSlopeVariable.cc.

References inv_slope, and right.

Referenced by build().

{
    inv_slope = (1.0 / (right - 1));
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

void PLearn::UnaryHardSlopeVariable::declareOptions ( OptionList ol) [static]

Declare options (data fields) for the class.

Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).

  static void MyDerivedClass::declareOptions(OptionList& ol)
  {
      declareOption(ol, "inputsize", &MyObject::inputsize_,
                    OptionBase::buildoption,
                    "The size of the input; it must be provided");
      declareOption(ol, "weights", &MyObject::weights,
                    OptionBase::learntoption,
                    "The learned model weights");
      inherited::declareOptions(ol);
  }
Parameters:
olList of options that is progressively being constructed for the current class.

Reimplemented from PLearn::UnaryVariable.

Definition at line 79 of file UnaryHardSlopeVariable.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::UnaryVariable::declareOptions(), left, and right.

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 68 of file UnaryHardSlopeVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 96 of file UnaryHardSlopeVariable.cc.

References PLearn::hard_slope(), i, PLearn::UnaryVariable::input, left, PLearn::Variable::nelems(), right, and PLearn::Variable::valuedata.

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

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 54 of file UnaryHardSlopeVariable.cc.

void PLearn::UnaryHardSlopeVariable::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 86 of file UnaryHardSlopeVariable.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:


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 68 of file UnaryHardSlopeVariable.h.

Definition at line 61 of file UnaryHardSlopeVariable.h.

Referenced by bprop(), and build_().

Definition at line 59 of file UnaryHardSlopeVariable.h.

Referenced by bprop(), declareOptions(), and fprop().

Definition at line 60 of file UnaryHardSlopeVariable.h.

Referenced by bprop(), build_(), declareOptions(), and fprop().


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