|
PLearn 0.1
|
VMat class that replicates small parts of a matrix (mini-batches), so that each mini-batch appears twice (consecutively). More...
#include <BatchVMatrix.h>


Public Member Functions | |
| BatchVMatrix () | |
| virtual string | classname () const |
| virtual OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual BatchVMatrix * | deepCopy (CopiesMap &copies) const |
| virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
| Transforms a shallow copy into a deep copy. | |
| virtual void | build () |
| Simply calls inherited::build() then build_(). | |
| virtual real | get (int i, int j) const |
| This method must be implemented in all subclasses. | |
| virtual void | put (int i, int j, real value) |
| This method must be implemented in all subclasses of writable matrices. | |
Static Public Member Functions | |
| 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 PPath & | declaringFile () |
| static void | declareOptions (OptionList &ol) |
| Declare this class' options. | |
Public Attributes | |
| VMat | m |
| Public build options. | |
| int | batch_size |
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ |
Private Types | |
| typedef VMatrix | inherited |
Private Member Functions | |
| void | build_ () |
| This does the actual building. | |
Private Attributes | |
| int | last_batch |
| int | last_batch_size |
VMat class that replicates small parts of a matrix (mini-batches), so that each mini-batch appears twice (consecutively).
Definition at line 50 of file BatchVMatrix.h.
typedef VMatrix PLearn::BatchVMatrix::inherited [private] |
Reimplemented from PLearn::VMatrix.
Definition at line 52 of file BatchVMatrix.h.
| PLearn::BatchVMatrix::BatchVMatrix | ( | ) |
Definition at line 50 of file BatchVMatrix.cc.
: batch_size(0), last_batch(-1), last_batch_size(-1) { }
| string PLearn::BatchVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file BatchVMatrix.cc.
| OptionList & PLearn::BatchVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file BatchVMatrix.cc.
| RemoteMethodMap & PLearn::BatchVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file BatchVMatrix.cc.
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file BatchVMatrix.cc.
| Object * PLearn::BatchVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 48 of file BatchVMatrix.cc.
| StaticInitializer BatchVMatrix::_static_initializer_ & PLearn::BatchVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file BatchVMatrix.cc.
| void PLearn::BatchVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::VMatrix.
Definition at line 81 of file BatchVMatrix.cc.
References PLearn::VMatrix::build(), and build_().
{
inherited::build();
build_();
}

| void PLearn::BatchVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::VMatrix.
Definition at line 90 of file BatchVMatrix.cc.
References batch_size, PLearn::VMatrix::fieldinfos, last_batch, last_batch_size, PLearn::VMat::length(), PLearn::VMatrix::length_, m, PLERROR, PLearn::VMat::width(), and PLearn::VMatrix::width_.
Referenced by build().
{
if (m) {
if (batch_size < 1)
PLERROR("BatchVMatrix::build_: the 'batch_size' option must be nonnegative");
width_ = m->width();
length_ = m->length() * 2;
fieldinfos = m->getFieldInfos();
last_batch = (m->length()-1) / batch_size;
last_batch_size = m->length() % batch_size;
if (last_batch_size == 0)
last_batch_size = batch_size;
}
}


| string PLearn::BatchVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file BatchVMatrix.cc.
| void PLearn::BatchVMatrix::declareOptions | ( | OptionList & | ol | ) | [static] |
Declare this class' options.
Reimplemented from PLearn::VMatrix.
Definition at line 60 of file BatchVMatrix.cc.
References batch_size, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), and m.
{
declareOption(ol, "m", &BatchVMatrix::m, OptionBase::buildoption,
"The matrix viewed by the BatchVMatrix\n");
declareOption(ol, "batch_size", &BatchVMatrix::batch_size, OptionBase::buildoption,
"The size of each mini-batch\n");
inherited::declareOptions(ol);
}

| static const PPath& PLearn::BatchVMatrix::declaringFile | ( | ) | [inline, static] |
| BatchVMatrix * PLearn::BatchVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::VMatrix.
Definition at line 48 of file BatchVMatrix.cc.
This method must be implemented in all subclasses.
Returns element (i,j).
Implements PLearn::VMatrix.
Definition at line 109 of file BatchVMatrix.cc.
References batch_size, last_batch, last_batch_size, and m.
{
int n_batch = i / (2 * batch_size);
int k = batch_size;
if (n_batch == last_batch) {
// This is the last batch
k = last_batch_size;
}
int i_ = n_batch * batch_size + (i - n_batch * 2 * batch_size) % k;
return m->get(i_, j);
}
| OptionList & PLearn::BatchVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file BatchVMatrix.cc.
| OptionMap & PLearn::BatchVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file BatchVMatrix.cc.
| RemoteMethodMap & PLearn::BatchVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 48 of file BatchVMatrix.cc.
| void PLearn::BatchVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::VMatrix.
Definition at line 72 of file BatchVMatrix.cc.
References PLearn::deepCopyField(), m, and PLearn::VMatrix::makeDeepCopyFromShallowCopy().
{
inherited::makeDeepCopyFromShallowCopy(copies);
deepCopyField(m, copies);
}

This method must be implemented in all subclasses of writable matrices.
Sets element (i,j) to value.
Reimplemented from PLearn::VMatrix.
Definition at line 123 of file BatchVMatrix.cc.
References batch_size, and m.
{
int n_batch = i / (2 * batch_size);
int i_ = n_batch * batch_size + (i - n_batch * 2 * batch_size) % batch_size;
m->put(i_, j, value);
}
Reimplemented from PLearn::VMatrix.
Definition at line 69 of file BatchVMatrix.h.
Definition at line 58 of file BatchVMatrix.h.
Referenced by build_(), declareOptions(), get(), and put().
int PLearn::BatchVMatrix::last_batch [private] |
Definition at line 62 of file BatchVMatrix.h.
int PLearn::BatchVMatrix::last_batch_size [private] |
Definition at line 63 of file BatchVMatrix.h.
Public build options.
Definition at line 57 of file BatchVMatrix.h.
Referenced by build_(), declareOptions(), get(), makeDeepCopyFromShallowCopy(), and put().
1.7.4