PLearn 0.1
|
selects randomly one row per bags from a multi instances conforming VMatrix and discard the multi instances bag information column. More...
#include <MultiToUniInstanceSelectRandomVMatrix.h>
Public Member Functions | |
MultiToUniInstanceSelectRandomVMatrix () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () 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 PPath & | declaringFile () |
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. |
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.
typedef SelectRowsVMatrix PLearn::MultiToUniInstanceSelectRandomVMatrix::inherited [private] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 59 of file MultiToUniInstanceSelectRandomVMatrix.h.
PLearn::MultiToUniInstanceSelectRandomVMatrix::MultiToUniInstanceSelectRandomVMatrix | ( | ) |
Default constructor.
Definition at line 56 of file MultiToUniInstanceSelectRandomVMatrix.cc.
: seed(0) { }
string PLearn::MultiToUniInstanceSelectRandomVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 54 of file MultiToUniInstanceSelectRandomVMatrix.cc.
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.
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_().
{ inherited::build(); build_(); }
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(); }
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] |
Declares this class' options.
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 61 of file MultiToUniInstanceSelectRandomVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SelectRowsVMatrix::declareOptions(), PLearn::SelectRowsVMatrix::indices, PLearn::SelectRowsVMatrix::indices_vmat, PLearn::OptionBase::nosave, PLearn::redeclareOption(), seed, and source_.
{ declareOption(ol, "seed", &MultiToUniInstanceSelectRandomVMatrix::seed, OptionBase::buildoption, "Random generator seed (>0) (exceptions : -1 = initialized from clock, 0 = no initialization)."); inherited::declareOptions(ol); // Redeclare some options. redeclareOption(ol, "indices", &MultiToUniInstanceSelectRandomVMatrix::indices, OptionBase::nosave, ""); redeclareOption(ol, "indices_vmat", &MultiToUniInstanceSelectRandomVMatrix::indices_vmat, OptionBase::nosave, ""); redeclareOption(ol, "source", &MultiToUniInstanceSelectRandomVMatrix::source_, OptionBase::buildoption, "Multi instances conforming source VMatrix"); }
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.
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().