PLearn 0.1
|
VMatrix that contains random samples from a VMatrix. More...
#include <RandomSamplesFromVMatrix.h>
Public Member Functions | |
RandomSamplesFromVMatrix () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual RandomSamplesFromVMatrix * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual PP< Dictionary > | getDictionary (int col) const |
Return the Dictionary object for a certain field, or a null pointer if there isn't one. | |
virtual void | getValues (int row, int col, Vec &values) const |
Returns the possible values for a certain field in the VMatrix. | |
virtual void | getValues (const Vec &input, int col, Vec &values) const |
Returns the possible values of a certain field (column) given the input. | |
Static Public Member Functions | |
static string | _classname_ () |
RowBufferedVMatrix. | |
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 () |
Public Attributes | |
VMat | source |
VMatrix from which the samples are taken. | |
real | flength |
If provided, will overwrite length by flength * source->length() | |
int32_t | seed |
Random number generator's seed. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
virtual void | getNewRow (int i, const Vec &v) const |
Fill the vector 'v' with the content of the i-th row. | |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Protected Attributes | |
PP< PRandom > | rgen |
Random number generator for selecting random sample. | |
Private Types | |
typedef RowBufferedVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
VMatrix that contains random samples from a VMatrix.
The samples are ALWAYS random, i.e. they are not pre-defined at building time. The only exception is when the same row is accessed many consecutive times, in which case the same example is returned.
Definition at line 55 of file RandomSamplesFromVMatrix.h.
typedef RowBufferedVMatrix PLearn::RandomSamplesFromVMatrix::inherited [private] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 57 of file RandomSamplesFromVMatrix.h.
PLearn::RandomSamplesFromVMatrix::RandomSamplesFromVMatrix | ( | ) |
Default constructor.
Definition at line 57 of file RandomSamplesFromVMatrix.cc.
string PLearn::RandomSamplesFromVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
OptionList & PLearn::RandomSamplesFromVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
RemoteMethodMap & PLearn::RandomSamplesFromVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
Object * PLearn::RandomSamplesFromVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
StaticInitializer RandomSamplesFromVMatrix::_static_initializer_ & PLearn::RandomSamplesFromVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
void PLearn::RandomSamplesFromVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::VMatrix.
Definition at line 116 of file RandomSamplesFromVMatrix.cc.
References PLearn::VMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::RandomSamplesFromVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::VMatrix.
Definition at line 95 of file RandomSamplesFromVMatrix.cc.
References PLearn::VMatrix::fieldinfos, flength, PLearn::VMatrix::inputsize_, PLearn::VMat::length(), PLearn::VMatrix::length_, rgen, seed, source, PLearn::VMatrix::targetsize_, PLearn::VMatrix::updateMtime(), PLearn::VMatrix::weightsize_, PLearn::VMat::width(), and PLearn::VMatrix::width_.
Referenced by build().
{ if(source) { updateMtime(source); if(flength > 0) length_ = int(flength * source->length()); if(length_ < 0) length_ = source->length(); if(seed != 0) rgen->manual_seed(seed); width_ = source->width(); if(inputsize_ < 0) inputsize_ = source->inputsize(); if(targetsize_ < 0) targetsize_ = source->targetsize(); if(weightsize_ < 0) weightsize_ = source->weightsize(); fieldinfos = source->fieldinfos; } }
string PLearn::RandomSamplesFromVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
void PLearn::RandomSamplesFromVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::VMatrix.
Definition at line 69 of file RandomSamplesFromVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), flength, seed, and source.
{ declareOption(ol, "source", &RandomSamplesFromVMatrix::source, OptionBase::buildoption, "VMatrix from which the samples are taken"); declareOption(ol, "flength", &RandomSamplesFromVMatrix::flength, OptionBase::buildoption, "If provided, will overwrite length by flength * source->length()"); declareOption(ol, "seed", &RandomSamplesFromVMatrix::seed, OptionBase::buildoption, "The initial seed for the random number generator used in this\n" "VMatrix, for sample selection.\n" "If -1 is provided, then a 'random' seed is chosen based on time\n" "of day, ensuring that different experiments run differently.\n" "If 0 is provided, no (re)initialization of the random number\n" "generator is performed.\n" "With a given positive seed, this VMatrix should always select\n" "the same sequence of samples."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::RandomSamplesFromVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 82 of file RandomSamplesFromVMatrix.h.
:
//##### Protected Options ###############################################
RandomSamplesFromVMatrix * PLearn::RandomSamplesFromVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
PP< Dictionary > PLearn::RandomSamplesFromVMatrix::getDictionary | ( | int | col | ) | const [virtual] |
Return the Dictionary object for a certain field, or a null pointer if there isn't one.
Reimplemented from PLearn::VMatrix.
Definition at line 131 of file RandomSamplesFromVMatrix.cc.
References source.
{ return source->getDictionary(col); }
void PLearn::RandomSamplesFromVMatrix::getNewRow | ( | int | i, |
const Vec & | v | ||
) | const [protected, virtual] |
Fill the vector 'v' with the content of the i-th row.
'v' is assumed to be the right size.
Implements PLearn::RowBufferedVMatrix.
Definition at line 64 of file RandomSamplesFromVMatrix.cc.
References PLearn::VMat::length(), rgen, and source.
OptionList & PLearn::RandomSamplesFromVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
OptionMap & PLearn::RandomSamplesFromVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
RemoteMethodMap & PLearn::RandomSamplesFromVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 55 of file RandomSamplesFromVMatrix.cc.
Returns the possible values for a certain field in the VMatrix.
Reimplemented from PLearn::VMatrix.
Definition at line 136 of file RandomSamplesFromVMatrix.cc.
References PLERROR.
{ PLERROR("In RandomSamplesFromVMatrix::getValues(): Cannot give possible values given a row index because samples are independent of the row index."); }
void PLearn::RandomSamplesFromVMatrix::getValues | ( | const Vec & | input, |
int | col, | ||
Vec & | values | ||
) | const [virtual] |
Returns the possible values of a certain field (column) given the input.
Reimplemented from PLearn::VMatrix.
Definition at line 141 of file RandomSamplesFromVMatrix.cc.
References source.
{ source->getValues(input,col,values); }
void PLearn::RandomSamplesFromVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 122 of file RandomSamplesFromVMatrix.cc.
References PLearn::deepCopyField(), PLearn::RowBufferedVMatrix::makeDeepCopyFromShallowCopy(), rgen, and source.
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(source, copies); deepCopyField(rgen, copies); }
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 82 of file RandomSamplesFromVMatrix.h.
If provided, will overwrite length by flength * source->length()
Definition at line 65 of file RandomSamplesFromVMatrix.h.
Referenced by build_(), and declareOptions().
PP<PRandom> PLearn::RandomSamplesFromVMatrix::rgen [protected] |
Random number generator for selecting random sample.
Definition at line 106 of file RandomSamplesFromVMatrix.h.
Referenced by build_(), getNewRow(), and makeDeepCopyFromShallowCopy().
Random number generator's seed.
Definition at line 67 of file RandomSamplesFromVMatrix.h.
Referenced by build_(), and declareOptions().
VMatrix from which the samples are taken.
Definition at line 63 of file RandomSamplesFromVMatrix.h.
Referenced by build_(), declareOptions(), getDictionary(), getNewRow(), getValues(), and makeDeepCopyFromShallowCopy().