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

WeightsVariable updated online, based on negative log-likelihood of the neighbors. More...

#include <NLLNeighborhoodWeightsVariable.h>

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

List of all members.

Public Member Functions

 NLLNeighborhoodWeightsVariable ()
 Default constructor, usually does nothing.
 NLLNeighborhoodWeightsVariable (Variable *neighbor_nlls, Variable *neighbor_indexes, int n, real alpha)
 Constructor initializing from two input variables.
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 ()
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
NLLNeighborhoodWeightsVariable
deepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

Static Public Member Functions

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

int n
 Total number of points to be weighted.
real alpha
 Exponential decay.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Protected Attributes

TVec< realonline_weights_log_sum
 Online log-sum of weights.
real log_alpha
 log(alpha)
real log_1_minus_alpha

Private Types

typedef BinaryVariable inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

WeightsVariable updated online, based on negative log-likelihood of the neighbors.

* NLLNeighborhoodWeightsVariable *

Definition at line 53 of file NLLNeighborhoodWeightsVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 55 of file NLLNeighborhoodWeightsVariable.h.


Constructor & Destructor Documentation

PLearn::NLLNeighborhoodWeightsVariable::NLLNeighborhoodWeightsVariable ( )

Default constructor, usually does nothing.

Definition at line 55 of file NLLNeighborhoodWeightsVariable.cc.

    : n(-1), alpha(-1)
{}
PLearn::NLLNeighborhoodWeightsVariable::NLLNeighborhoodWeightsVariable ( Variable neighbor_nlls,
Variable neighbor_indexes,
int  n,
real  alpha 
)

Constructor initializing from two input variables.

Definition at line 60 of file NLLNeighborhoodWeightsVariable.cc.

References build().

    : inherited(neighbor_nlls, neighbor_indexes, neighbor_nlls->length(), 1),
      n(the_n), alpha(the_alpha)
{
    build();
}

Here is the call graph for this function:


Member Function Documentation

string PLearn::NLLNeighborhoodWeightsVariable::_classname_ ( ) [static]
OptionList & PLearn::NLLNeighborhoodWeightsVariable::_getOptionList_ ( ) [static]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Implements PLearn::Variable.

Definition at line 102 of file NLLNeighborhoodWeightsVariable.cc.

{
    
}
void PLearn::NLLNeighborhoodWeightsVariable::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::BinaryVariable.

Definition at line 114 of file NLLNeighborhoodWeightsVariable.cc.

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

Referenced by NLLNeighborhoodWeightsVariable().

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::NLLNeighborhoodWeightsVariable::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::BinaryVariable.

Definition at line 143 of file NLLNeighborhoodWeightsVariable.cc.

References alpha, PLearn::TVec< T >::fill(), PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, log_1_minus_alpha, log_alpha, MISSING_VALUE, n, online_weights_log_sum, pl_log, PLERROR, PLearn::TVec< T >::resize(), and PLearn::Var::width().

Referenced by build().

{
    if(input1 && input2)
    {
        if(n<=0)
            PLERROR("In NLLNeighborhoodWeightsVariable::build_(): n must be > 0");
        if(alpha <= 0 || alpha >= 1)
            PLERROR("In NLLNeighborhoodWeightsVariable::build_(): alpha must be in ]0,1[");
        log_alpha = pl_log(alpha);
        log_1_minus_alpha = pl_log(1-alpha);
        online_weights_log_sum.resize(n);
        online_weights_log_sum.fill(MISSING_VALUE);
        if(input1->width() != 1)
            PLERROR("In NLLNeighborhoodWeightsVariable::build_(): input1 must be column vector");
        if(input2->width() != 1)
            PLERROR("In NLLNeighborhoodWeightsVariable::build_(): input2 must be column vector");
        if(input1->size() != input2->size())
            PLERROR("In NLLNeighborhoodWeightsVariable::build_(): input1 and input2 must be of same size");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

void PLearn::NLLNeighborhoodWeightsVariable::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::BinaryVariable.

Definition at line 129 of file NLLNeighborhoodWeightsVariable.cc.

References alpha, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::BinaryVariable::declareOptions(), and n.

{
    declareOption(ol, "n", &NLLNeighborhoodWeightsVariable::n,
                  OptionBase::buildoption,
                  "Total number of points to be weighted");

    declareOption(ol, "alpha", &NLLNeighborhoodWeightsVariable::alpha,
                  OptionBase::buildoption,
                  "Exponential decay");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::BinaryVariable.

Definition at line 90 of file NLLNeighborhoodWeightsVariable.h.

:
    //#####  Protected Options  ###############################################
NLLNeighborhoodWeightsVariable * PLearn::NLLNeighborhoodWeightsVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::BinaryVariable.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 76 of file NLLNeighborhoodWeightsVariable.cc.

References PLearn::exp(), i, PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, PLearn::is_missing(), PLearn::TVec< T >::length(), PLearn::Variable::length(), log_1_minus_alpha, log_alpha, PLearn::logadd(), n, online_weights_log_sum, PLERROR, and PLearn::Variable::valuedata.

{
    int index;
    for(int i=0; i<length(); i++)
    {
        index = (int)input2->valuedata[i];
        #ifdef BOUNDCHECK
        if(index < 0 || index >= online_weights_log_sum.length())
            PLERROR("In NLLNeighborhoodWeightsVariable::fprop(): input2->valuedata[%d] should be between 0 and n=%d",index,n);
        #endif
        if(is_missing(online_weights_log_sum[index]))
        {
            online_weights_log_sum[index] = -1*input1->valuedata[i];
        }
        else
        {
            online_weights_log_sum[index] = logadd(log_1_minus_alpha + online_weights_log_sum[index], log_alpha - input1->valuedata[i]);
        }
    }
    for(int i=0; i<length(); i++)
    {
        valuedata[i] = exp(-input1->valuedata[i] - online_weights_log_sum[(int)input2->valuedata[i]]);
    }
    //cout << "weights="<< value << endl;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file NLLNeighborhoodWeightsVariable.cc.

void PLearn::NLLNeighborhoodWeightsVariable::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::BinaryVariable.

Definition at line 120 of file NLLNeighborhoodWeightsVariable.cc.

References PLearn::deepCopyField(), PLearn::BinaryVariable::makeDeepCopyFromShallowCopy(), and online_weights_log_sum.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    deepCopyField(online_weights_log_sum, copies);

    //PLERROR("NLLNeighborhoodWeightsVariable::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

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

References PLearn::BinaryVariable::input1, PLearn::BinaryVariable::input2, and PLearn::Var::length().

{
    if (input1 && input2) {
        l = input1->length();
        w = 1;
    } else
        l = w = 0;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::BinaryVariable.

Definition at line 90 of file NLLNeighborhoodWeightsVariable.h.

Exponential decay.

Definition at line 63 of file NLLNeighborhoodWeightsVariable.h.

Referenced by build_(), and declareOptions().

Definition at line 106 of file NLLNeighborhoodWeightsVariable.h.

Referenced by build_(), and fprop().

log(alpha)

Definition at line 105 of file NLLNeighborhoodWeightsVariable.h.

Referenced by build_(), and fprop().

Total number of points to be weighted.

Definition at line 61 of file NLLNeighborhoodWeightsVariable.h.

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

Online log-sum of weights.

Definition at line 103 of file NLLNeighborhoodWeightsVariable.h.

Referenced by build_(), fprop(), and makeDeepCopyFromShallowCopy().


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