|
PLearn 0.1
|
#include <IntStream.h>


Public Member Functions | |
| IntStreamVMatrix () | |
| IntStreamVMatrix (IntStream &s, int window_size, int dummy_input, int eos) | |
| virtual void | getRow (int i, Vec v) const |
| These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine) | |
Protected Attributes | |
| PP< IntStream > | stream |
| where the data actually is | |
| int | position |
| position in the stream corresponding to the current window | |
| int | dummy_input |
| int | end_of_sequence_symbol |
Definition at line 100 of file IntStream.h.
| PLearn::IntStreamVMatrix::IntStreamVMatrix | ( | ) | [inline] |
Definition at line 116 of file IntStream.h.
{}
| PLearn::IntStreamVMatrix::IntStreamVMatrix | ( | IntStream & | s, |
| int | window_size, | ||
| int | dummy_input, | ||
| int | eos | ||
| ) |
Definition at line 55 of file IntStream.cc.
References PLearn::RowBufferedVMatrix::current_row, dummy_input, and PLearn::TVec< T >::fill().
: RowBufferedVMatrix(s.size(),window_size), stream(&s), position(-1), dummy_input(dummyinput), end_of_sequence_symbol(eos) { current_row.fill(dummy_input); }

These methods do not usually need to be overridden in subclasses (default versions call getSubRow, which should do just fine)
Copies row i into v (which must have appropriate length equal to the VMat's width).
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 62 of file IntStream.cc.
References PLearn::RowBufferedVMatrix::current_row, dummy_input, end_of_sequence_symbol, i, j, PLERROR, position, stream, USE_JS_HACK, and PLearn::VMatrix::width().
{
if (i==position+1) // most frequent case
{
int j=1;
if (current_row[width()-1]==end_of_sequence_symbol)
{
for (;j<width()-1;j++) current_row[j-1]=dummy_input;
current_row[j++ - 1]=end_of_sequence_symbol;
}
else
for (;j<width();j++)
current_row[j-1]=current_row[j];
#if USE_JS_HACK
{
real next=stream->next();
if (next>=MAX_VOC_SIZE) next = MAX_VOC_SIZE-1;
current_row[j-1] = next;
}
#else
current_row[j-1]=stream->next();
#endif
}
else if (i!=position)
{
if (i>=width())
{
stream->seek(i-width()+1);
for (int j=0;j<width();j++)
#if USE_JS_HACK
{
real next=stream->next();
if (next>=MAX_VOC_SIZE) next = MAX_VOC_SIZE-1;
current_row[j] = next;
}
#else
current_row[j]=stream->next();
#endif
} else
{
if (i<0) PLERROR("IntStreamVMat::getRow at row %d < 0!",i);
stream->seek(0);
int j=0;
for (;j<width()-i-1;j++)
current_row[j]=dummy_input;
for (;j<width();j++)
#if USE_JS_HACK
{
real next=stream->next();
if (next>=MAX_VOC_SIZE) next = MAX_VOC_SIZE-1;
current_row[j] = next;
}
#else
current_row[j]=stream->next();
#endif
}
}
position=i;
v << current_row;
}

int PLearn::IntStreamVMatrix::dummy_input [protected] |
current_row is a window on the stream, with current_row[width()-1] being the element at position 'position' of the stream. Note also that the first width()-1 elements of current row when at position 0 or "end of sequence" are filled with a special value, dummy_input:
Definition at line 109 of file IntStream.h.
Referenced by getRow(), and IntStreamVMatrix().
int PLearn::IntStreamVMatrix::end_of_sequence_symbol [protected] |
When the end_of_sequence_symbol is encountered, the symbols that follow are "isolated" from the symbols that precede, i.e. when this symbol moves from element width()-1 to width()-1, the elements that precede are replaced by 'dummy_input'.
Definition at line 114 of file IntStream.h.
Referenced by getRow().
int PLearn::IntStreamVMatrix::position [mutable, protected] |
position in the stream corresponding to the current window
Definition at line 103 of file IntStream.h.
Referenced by getRow().
PP<IntStream> PLearn::IntStreamVMatrix::stream [protected] |
1.7.4