PLearn 0.1
|
This VMat delay the last targetsize entries of a source VMat by a certain horizon. More...
#include <TemporalHorizonVMatrix.h>
Public Member Functions | |
TemporalHorizonVMatrix (bool call_build_=false) | |
Also copies the original fieldinfos upon construction. | |
TemporalHorizonVMatrix (VMat the_source, int the_horizon, int target_size, bool call_build_=false) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TemporalHorizonVMatrix * | 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 real | get (int i, int j) const |
These methods are implemented by buffering calls to getNewRow. | |
virtual void | put (int i, int j, real value) |
This method must be implemented in all subclasses of writable matrices. | |
virtual real | getStringVal (int col, const string &str) const |
Returns value associated with a string (or MISSING_VALUE if there's no association for this string). | |
virtual string | getValString (int col, real val) const |
Returns the string associated with value val for field# col. | |
virtual string | getString (int row, int col) const |
Returns element as a string, even if value doesn't map to a string, in which case tostring(value) is returned. | |
virtual const map< string, real > & | getStringToRealMapping (int col) const |
returns the whole string->value mapping | |
virtual const map< real, string > & | getRealToStringMapping (int col) const |
Returns the real->string mapping for column 'col'. | |
virtual void | reset_dimensions () |
In case the dimensions of an underlying VMat has changed, recompute it. | |
virtual real | dot (int i1, int i2, int inputsize) const |
Returns the dot product between row i1 and row i2 (considering only the inputsize first elements). | |
virtual real | dot (int i, const Vec &v) const |
Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered). | |
Static Public Member Functions | |
static string | _classname_ () |
TemporalHorizonVMatrix. | |
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. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Attributes | |
int | horizon |
int | targetsize |
TVec< int > | row_delay |
Private Types | |
typedef SourceVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
This VMat delay the last targetsize entries of a source VMat by a certain horizon.
Definition at line 55 of file TemporalHorizonVMatrix.h.
typedef SourceVMatrix PLearn::TemporalHorizonVMatrix::inherited [private] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file TemporalHorizonVMatrix.h.
PLearn::TemporalHorizonVMatrix::TemporalHorizonVMatrix | ( | bool | call_build_ = false | ) |
Also copies the original fieldinfos upon construction.
Definition at line 54 of file TemporalHorizonVMatrix.cc.
: inherited(call_build_) { // don't call build_() because it would do nothing /* if( call_build_ ) build_(); */ }
PLearn::TemporalHorizonVMatrix::TemporalHorizonVMatrix | ( | VMat | the_source, |
int | the_horizon, | ||
int | target_size, | ||
bool | call_build_ = false |
||
) |
Definition at line 62 of file TemporalHorizonVMatrix.cc.
References PLearn::VMatrix::defineSizes(), PLearn::VMatrix::fieldinfos, horizon, i, PLearn::TVec< T >::resize(), row_delay, PLearn::SourceVMatrix::source, PLearn::VMatrix::targetsize(), and PLearn::VMatrix::width().
: inherited(the_source, the_source.length()-the_horizon, the_source->width(), call_build_), horizon(the_horizon), targetsize(target_size) { fieldinfos = source->fieldinfos; row_delay.resize(width()); for (int i=0; i<width(); i++) row_delay[i] = i<width()-targetsize ? 0 : horizon; defineSizes(source->inputsize(), source->targetsize(), source->weightsize()); // don't call build_() because it would do nothing /* if( call_build_ ) build_(); */ }
string PLearn::TemporalHorizonVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
OptionList & PLearn::TemporalHorizonVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
RemoteMethodMap & PLearn::TemporalHorizonVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
Object * PLearn::TemporalHorizonVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
StaticInitializer TemporalHorizonVMatrix::_static_initializer_ & PLearn::TemporalHorizonVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
void PLearn::TemporalHorizonVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::SourceVMatrix.
Definition at line 148 of file TemporalHorizonVMatrix.cc.
References PLearn::SourceVMatrix::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::TemporalHorizonVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 157 of file TemporalHorizonVMatrix.cc.
References PLearn::VMatrix::defineSizes(), PLearn::VMatrix::fieldinfos, horizon, i, PLearn::VMat::length(), PLearn::VMatrix::length_, PLearn::TVec< T >::resize(), row_delay, PLearn::SourceVMatrix::source, PLearn::VMatrix::targetsize(), PLearn::VMatrix::updateMtime(), PLearn::VMatrix::width(), PLearn::VMat::width(), and PLearn::VMatrix::width_.
Referenced by build().
{ if (source) { updateMtime(source); length_ = source->length()-horizon; width_ = source->width(); fieldinfos = source->fieldinfos; row_delay.resize(width()); for (int i=0; i<width(); i++) row_delay[i] = i<width()-targetsize ? 0 : horizon; defineSizes(source->inputsize(), source->targetsize(), source->weightsize()); } }
string PLearn::TemporalHorizonVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
void PLearn::TemporalHorizonVMatrix::declareOptions | ( | OptionList & | ol | ) | [static] |
Declares this class' options.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 123 of file TemporalHorizonVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), horizon, PLearn::OptionBase::learntoption, PLearn::OptionBase::nosave, PLearn::SourceVMatrix::source, and PLearn::VMatrix::targetsize().
{ declareOption(ol, "distr", &TemporalHorizonVMatrix::source, (OptionBase::learntoption | OptionBase::nosave), "DEPRECATED - Use 'source' instead."); declareOption(ol, "horizon", &TemporalHorizonVMatrix::horizon, OptionBase::buildoption, "The temporal value by which to delay the source VMat"); declareOption(ol, "targetsize", &TemporalHorizonVMatrix::targetsize, OptionBase::buildoption, "The number of last entries to delay"); inherited::declareOptions(ol); }
static const PPath& PLearn::TemporalHorizonVMatrix::declaringFile | ( | ) | [inline, static] |
TemporalHorizonVMatrix * PLearn::TemporalHorizonVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
Returns the dot product between row i1 and row i2 (considering only the inputsize first elements).
The default version in VMatrix is somewhat inefficient, as it repeatedly calls get(i,j) The default version in RowBufferedVMatrix is a little better as it buffers the 2 Vecs between calls in case one of them is needed again. But the real strength of this method is for specialised and efficient versions in subbclasses. This method is typically used by SmartKernels so that they can compute kernel values between input samples efficiently.
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 92 of file TemporalHorizonVMatrix.cc.
References PLearn::VMatrix::inputsize(), row_delay, and PLearn::SourceVMatrix::source.
{ real res = 0.; for(int k=0; k<inputsize; k++) res += source->get(i1+row_delay[k],k)*source->get(i2+row_delay[k],k); return res; }
Returns the result of the dot product between row i and the given vec (only v.length() first elements of row i are considered).
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 100 of file TemporalHorizonVMatrix.cc.
References PLearn::TVec< T >::length(), row_delay, and PLearn::SourceVMatrix::source.
{ real res = 0.; for(int k=0; k<v.length(); k++) res += source->get(i+row_delay[k],k)*v[k]; return res; }
These methods are implemented by buffering calls to getNewRow.
returns element (i,j)
Reimplemented from PLearn::RowBufferedVMatrix.
Definition at line 86 of file TemporalHorizonVMatrix.cc.
References row_delay, and PLearn::SourceVMatrix::source.
OptionList & PLearn::TemporalHorizonVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
OptionMap & PLearn::TemporalHorizonVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
const map< real, string > & PLearn::TemporalHorizonVMatrix::getRealToStringMapping | ( | int | col | ) | const [virtual] |
Returns the real->string mapping for column 'col'.
Reimplemented from PLearn::VMatrix.
Definition at line 120 of file TemporalHorizonVMatrix.cc.
References PLearn::SourceVMatrix::source.
{ return source->getRealToStringMapping(col);}
RemoteMethodMap & PLearn::TemporalHorizonVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 52 of file TemporalHorizonVMatrix.cc.
Returns element as a string, even if value doesn't map to a string, in which case tostring(value) is returned.
Reimplemented from PLearn::VMatrix.
Definition at line 114 of file TemporalHorizonVMatrix.cc.
References row_delay, and PLearn::SourceVMatrix::source.
const map< string, real > & PLearn::TemporalHorizonVMatrix::getStringToRealMapping | ( | int | col | ) | const [virtual] |
returns the whole string->value mapping
Reimplemented from PLearn::VMatrix.
Definition at line 117 of file TemporalHorizonVMatrix.cc.
References PLearn::SourceVMatrix::source.
{ return source->getStringToRealMapping(col);}
Returns value associated with a string (or MISSING_VALUE if there's no association for this string).
Reimplemented from PLearn::VMatrix.
Definition at line 108 of file TemporalHorizonVMatrix.cc.
References PLearn::SourceVMatrix::source.
{ return source->getStringVal(col, str); }
Returns the string associated with value val for field# col.
Or returns "" if no string is associated.
Reimplemented from PLearn::VMatrix.
Definition at line 111 of file TemporalHorizonVMatrix.cc.
References PLearn::SourceVMatrix::source.
{ return source->getValString(col,val); }
void PLearn::TemporalHorizonVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 140 of file TemporalHorizonVMatrix.cc.
References PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy().
{ inherited::makeDeepCopyFromShallowCopy(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 89 of file TemporalHorizonVMatrix.cc.
References row_delay, and PLearn::SourceVMatrix::source.
virtual void PLearn::TemporalHorizonVMatrix::reset_dimensions | ( | ) | [inline, virtual] |
In case the dimensions of an underlying VMat has changed, recompute it.
Reimplemented from PLearn::VMatrix.
Definition at line 91 of file TemporalHorizonVMatrix.h.
Reimplemented from PLearn::SourceVMatrix.
Definition at line 75 of file TemporalHorizonVMatrix.h.
int PLearn::TemporalHorizonVMatrix::horizon [protected] |
Definition at line 62 of file TemporalHorizonVMatrix.h.
Referenced by build_(), declareOptions(), and TemporalHorizonVMatrix().
TVec<int> PLearn::TemporalHorizonVMatrix::row_delay [protected] |
Definition at line 64 of file TemporalHorizonVMatrix.h.
Referenced by build_(), dot(), get(), getString(), put(), and TemporalHorizonVMatrix().
int PLearn::TemporalHorizonVMatrix::targetsize [protected] |
Definition at line 63 of file TemporalHorizonVMatrix.h.