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

#include <NoBpropVariable.h>

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

List of all members.

Public Member Functions

 NoBpropVariable ()
 Default constructor for persistence.
 NoBpropVariable (Variable *input, real the_gradient_scaling_factor=0.0)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual NoBpropVariabledeepCopy (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.
 NoBpropVariable ()
 Default constructor for persistence.
 NoBpropVariable (Variable *input, real *the_gradient_scaling_factor)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual NoBpropVariabledeepCopy (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_ ()
 NoBpropVariable.
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 string _classname_ ()
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.

Public Attributes

real gradient_scaling_factor
realgradient_scaling_factor

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

void build_ ()
 Object-specific post-constructor.
void build_ ()
 Object-specific post-constructor.

Private Types

typedef UnaryVariable inherited
typedef UnaryVariable inherited

Detailed Description

* NoBpropVariable *

Variable that copies its unique input, and can completely block the flow of gradient backward, or optionally let if flow partially (with an optional coefficient), i.e. fprop: output = input bprop: dC/dinput = gradient_scaling_factor * dC/doutput

Definition at line 61 of file var/NoBpropVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file var/NoBpropVariable.h.

Reimplemented from PLearn::UnaryVariable.

Definition at line 63 of file learners_experimental/NoBpropVariable.h.


Constructor & Destructor Documentation

PLearn::NoBpropVariable::NoBpropVariable ( ) [inline]

Default constructor for persistence.

Definition at line 70 of file var/NoBpropVariable.h.

PLearn::NoBpropVariable::NoBpropVariable ( Variable input,
real  the_gradient_scaling_factor = 0.0 
)

Definition at line 61 of file var/NoBpropVariable.cc.

References build_().

    : inherited(input, input->length(), input->width()),
      gradient_scaling_factor(the_gradient_scaling_factor)
{
    build_();
}

Here is the call graph for this function:

PLearn::NoBpropVariable::NoBpropVariable ( ) [inline]

Default constructor for persistence.

Definition at line 70 of file learners_experimental/NoBpropVariable.h.

PLearn::NoBpropVariable::NoBpropVariable ( Variable input,
real the_gradient_scaling_factor 
)

Definition at line 61 of file learners_experimental/NoBpropVariable.cc.

References build_().

    : inherited(input, input->length(), input->width()),
      gradient_scaling_factor(the_gradient_scaling_factor)
{
    build_();
}

Here is the call graph for this function:


Member Function Documentation

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

NoBpropVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

static void PLearn::NoBpropVariable::_static_initialize_ ( ) [static]

Reimplemented from PLearn::UnaryVariable.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 105 of file var/NoBpropVariable.cc.

References gradient_scaling_factor, PLearn::Variable::gradientdata, and PLearn::UnaryVariable::input.

{
    if(gradient_scaling_factor!=0)
    {
        for(int k=0; k<input->nelems(); k++)
            input->gradientdata[k] += gradient_scaling_factor*gradientdata[k];
    }
}
virtual void PLearn::NoBpropVariable::bprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

virtual void PLearn::NoBpropVariable::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.

void PLearn::NoBpropVariable::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 69 of file var/NoBpropVariable.cc.

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

Here is the call graph for this function:

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

void PLearn::NoBpropVariable::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 76 of file var/NoBpropVariable.cc.

Referenced by build(), and NoBpropVariable().

{
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

void PLearn::NoBpropVariable::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 81 of file var/NoBpropVariable.cc.

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

{
    declareOption(ol, "gradient_scaling_factor", &NoBpropVariable::gradient_scaling_factor, 
                  OptionBase::buildoption, "Factor by which the gradient flow is scaled. A value\n"
                  "of zero completely prevents backward propagation of gradient to its input variable.");
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

static void PLearn::NoBpropVariable::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.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 75 of file learners_experimental/NoBpropVariable.h.

:
    void build_();
static const PPath& PLearn::NoBpropVariable::declaringFile ( ) [inline, static]

Reimplemented from PLearn::UnaryVariable.

Definition at line 75 of file var/NoBpropVariable.h.

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

Reimplemented from PLearn::UnaryVariable.

NoBpropVariable * PLearn::NoBpropVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 98 of file var/NoBpropVariable.cc.

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

{
    for(int k=0; k<input->nelems(); k++)
        valuedata[k] = input->valuedata[k];
}
virtual void PLearn::NoBpropVariable::fprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 59 of file var/NoBpropVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

void PLearn::NoBpropVariable::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 var/NoBpropVariable.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:

virtual void PLearn::NoBpropVariable::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.


Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 75 of file var/NoBpropVariable.h.

Definition at line 66 of file learners_experimental/NoBpropVariable.h.

Definition at line 66 of file var/NoBpropVariable.h.

Referenced by bprop(), and declareOptions().


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