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

selects randomly one row per bags from a multi instances conforming VMatrix and discard the multi instances bag information column. More...

#include <MultiToUniInstanceSelectRandomVMatrix.h>

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

List of all members.

Public Member Functions

 MultiToUniInstanceSelectRandomVMatrix ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
MultiToUniInstanceSelectRandomVMatrix
deepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().

Static Public Member Functions

static string _classname_ ()
 SelectRowsVMatrix.
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)
 Declares this class' options.

Public Attributes

VMat source_
int32_t seed
 Random number generator seed.

Static Public Attributes

static StaticInitializer _static_initializer_

Private Types

typedef SelectRowsVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

selects randomly one row per bags from a multi instances conforming VMatrix and discard the multi instances bag information column.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 59 of file MultiToUniInstanceSelectRandomVMatrix.h.


Constructor & Destructor Documentation

PLearn::MultiToUniInstanceSelectRandomVMatrix::MultiToUniInstanceSelectRandomVMatrix ( )

Default constructor.

Definition at line 56 of file MultiToUniInstanceSelectRandomVMatrix.cc.

    : seed(0)
{
}

Member Function Documentation

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

void PLearn::MultiToUniInstanceSelectRandomVMatrix::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 79 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 85 of file MultiToUniInstanceSelectRandomVMatrix.cc.

References PLearn::SelectRowsVMatrix::build(), PLearn::VMatrix::fieldinfos, PLearn::SelectRowsVMatrix::indices, PLearn::SelectRowsVMatrix::indices_vmat, PLearn::VMatrix::inputsize_, PLearn::VMat::length(), PLearn::manual_seed(), PLERROR, PLearn::TVec< T >::push_back(), PLearn::TVec< T >::resize(), seed, PLearn::VMatrix::setFieldInfos(), PLearn::SourceVMatrix::source, source_, PLearn::VMatrix::targetsize_, PLearn::uniform_sample(), PLearn::VMatrix::updateMtime(), PLearn::VMatrix::weightsize_, and PLearn::VMatrix::width_.

Referenced by build().

{

    // Seeding the random number generator
    if (seed == -1)
        PLearn::seed();
    else if (seed > 0)
        PLearn::manual_seed(seed);
    else if (seed != 0)
        PLERROR("In MultiToUniInstanceSelectRandomVMatrix::build_ - The seed must be either -1 or >= 0");

    updateMtime(indices_vmat);
    updateMtime(source_);

    // Building the source VMatrix (uni instances conforming version of source_)
    source = new SubVMatrix(source_, 0, 0, source_->length(), source_->inputsize()+source_->targetsize() - 1);
    source->defineSizes(source_->inputsize(), source_->targetsize()-1, 0);

    width_ = source->inputsize() + source->targetsize() + source->weightsize();
    inputsize_ = source->inputsize();
    targetsize_ = source->targetsize();
    weightsize_ = source->weightsize();

    // Copy the appropriate fields informations
    if (source->getFieldInfos().size() > 0)
    {
        fieldinfos.resize(width_);
        this->setFieldInfos(source->getFieldInfos());
    }
// Building the indices list that correspond to choosing randomly one instance per bag.
/* Notes for this task :
   The bag signal values meaning :
   1 means the first instance of the bag
   2 means the last instance of the bag
   3 is for a bag with a single row (= 1+2)
   0 is for intermediate instances.
*/

    int bag_signal_column = source_->inputsize() + source_->targetsize() - 1;
    int first_row = 0;

    indices.resize(0); // This get rid of the user's build option value.
    for(int row=0; row<source_->length(); row++)
    {
        switch(int(source_->get(row, bag_signal_column)))
        {
        case 1:
            first_row = row;
            break;
        case 2:
            indices.push_back(first_row+(int)(uniform_sample()*(row-first_row+1)));
            break;
        case 3:
            indices.push_back(row);
            break;
        };
    }
    inherited::build();

}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

void PLearn::MultiToUniInstanceSelectRandomVMatrix::declareOptions ( OptionList ol) [static]
static const PPath& PLearn::MultiToUniInstanceSelectRandomVMatrix::declaringFile ( ) [inline, static]

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 79 of file MultiToUniInstanceSelectRandomVMatrix.h.

:

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.


Member Data Documentation

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 79 of file MultiToUniInstanceSelectRandomVMatrix.h.

Random number generator seed.

Definition at line 70 of file MultiToUniInstanceSelectRandomVMatrix.h.

Referenced by build_(), and declareOptions().

Definition at line 63 of file MultiToUniInstanceSelectRandomVMatrix.h.

Referenced by build_(), and declareOptions().


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