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

VMat class that replicates small parts of a matrix (mini-batches), so that each mini-batch appears twice (consecutively). More...

#include <BatchVMatrix.h>

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

List of all members.

Public Member Functions

 BatchVMatrix ()
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual BatchVMatrixdeepCopy (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 PPathdeclaringFile ()
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

Detailed Description

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.


Member Typedef Documentation

Reimplemented from PLearn::VMatrix.

Definition at line 52 of file BatchVMatrix.h.


Constructor & Destructor Documentation

PLearn::BatchVMatrix::BatchVMatrix ( )

Definition at line 50 of file BatchVMatrix.cc.


Member Function Documentation

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.

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

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_().

Here is the call graph for this function:

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;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::VMatrix.

Definition at line 69 of file BatchVMatrix.h.

:

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

Reimplemented from PLearn::VMatrix.

Definition at line 48 of file BatchVMatrix.cc.

real PLearn::BatchVMatrix::get ( int  i,
int  j 
) const [virtual]

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().

Here is the call graph for this function:

void PLearn::BatchVMatrix::put ( int  i,
int  j,
real  value 
) [virtual]

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);
}

Member Data Documentation

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().

Definition at line 62 of file BatchVMatrix.h.

Referenced by build_(), and get().

Definition at line 63 of file BatchVMatrix.h.

Referenced by build_(), and get().

Public build options.

Definition at line 57 of file BatchVMatrix.h.

Referenced by build_(), declareOptions(), get(), makeDeepCopyFromShallowCopy(), and put().


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