#include <ForwardVMatrix.h>
Inheritance diagram for PLearn::ForwardVMatrix:
Public Member Functions | |
ForwardVMatrix () | |
ForwardVMatrix (VMat vm) | |
PLEARN_DECLARE_OBJECT (ForwardVMatrix) | |
virtual void | build () |
Should call simply inherited::build(), then this class's build_(). | |
void | setVMat (VMat the_vm) |
This allows to set the underlying vmat. | |
virtual string | getValString (int col, real val) const |
returns the string associated with value val for field# col. | |
virtual real | getStringVal (int col, const string &str) const |
return value associated with a string. Default returns NaN | |
virtual string | getString (int row, int col) const |
returns element as a string, even if its a number (which is always the case unless class is StrTableVMatrix | |
map< string, real > | getStringMapping (int col) const |
returns the whole string->value mapping | |
virtual const map< string, real > & | getStringToRealMapping (int col) const |
returns the string->value mapping for field 'fld' | |
virtual const map< real, string > & | getRealToStringMapping (int col) const |
returns the value->string mapping for field 'fld' | |
virtual void | computeStats () |
virtual void | save (const string &filename) const |
returns the cooccurence statistics conditioned on the given field (within the ranges returned by getRanges() ) The results are cached in file stats#.psave (where # stands for the condfield index) | |
virtual void | savePMAT (const string &pmatfile) const |
virtual void | saveDMAT (const string &dmatdir) const |
virtual void | saveAMAT (const string &amatfile) const |
virtual real | get (int i, int j) const |
returns element (i,j) | |
virtual void | put (int i, int j, real value) |
sets element (i,j) to value | |
virtual void | getSubRow (int i, int j, Vec v) const |
fills v with the subrow i lying between columns j (inclusive) and j+v.length() (exclusive) | |
virtual void | putSubRow (int i, int j, Vec v) |
virtual void | appendRow (Vec v) |
This method must be implemented for matrices that are allowed to grow. | |
virtual void | getRow (int i, Vec v) const |
copies row i into v (which must have appropriate length equal to the VMat's width) | |
virtual void | putRow (int i, Vec v) |
virtual void | fill (real value) |
virtual void | getMat (int i, int j, Mat m) const |
copies the submatrix starting at i,j into m (which must have appropriate length and width) | |
virtual void | putMat (int i, int j, Mat m) |
copies matrix m at position i,j of this VMat | |
virtual void | getColumn (int i, Vec v) const |
copies column i into v (which must have appropriate length equal to the VMat's length) | |
virtual Mat | toMat () const |
virtual void | compacify () |
The default implementation of this method does nothing But subclasses may overload it to reallocate memory to exactly what is needed and no more. | |
virtual void | reset_dimensions () |
in case the dimensions of an underlying vmat has changed, recompute it | |
virtual VMat | subMat (int i, int j, int l, int w) |
virtual real | dot (int i1, int i2, int inputsize) const |
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). | |
virtual void | getRow (int i, VarArray &inputs) const |
Assigns the value of the Vars in the list (the total size of all the vars in the list must equal width() ). | |
virtual void | oldwrite (ostream &out) const |
virtual void | oldread (istream &in) |
DEPRECATED For backward compatibility with old saved object. | |
void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
virtual void | evaluateKernel (Ker ker, int v1_startcol, int v1_ncols, const Vec &v2, const Vec &result, int startrow=0, int nrows=-1) const |
virtual real | evaluateKernelSum (Ker ker, int v1_startcol, int v1_ncols, const Vec &v2, int startrow=0, int nrows=-1, int ignore_this_row=-1) const |
returns sum_i [ ker( m(i).subVec(v1_startcol,v1_ncols) , v2) ] | |
virtual real | evaluateKernelWeightedTargetSum (Ker ker, int v1_startcol, int v1_ncols, const Vec &v2, int t_startcol, int t_ncols, Vec &targetsum, int startrow=0, int nrows=-1, int ignore_this_row=-1) const |
targetsum := sum_i [ m(i).subVec(t_startcol,t_ncols) * ker( m(i).subVec(v1_startcol,v1_ncols) , v2) ] and returns sum_i [ ker( m(i).subVec(v1_startcol,v1_ncols) , v2) ] | |
virtual TVec< pair< real, int > > | evaluateKernelTopN (int N, Ker ker, int v1_startcol, int v1_ncols, const Vec &v2, int startrow=0, int nrows=-1, int ignore_this_row=-1) const |
virtual TVec< pair< real, int > > | evaluateKernelBottomN (int N, Ker ker, int v1_startcol, int v1_ncols, const Vec &v2, int startrow=0, int nrows=-1, int ignore_this_row=-1) const |
same as evaluateKernelTopN but will look for the N smallest values instead of top values. | |
virtual void | accumulateXtY (int X_startcol, int X_ncols, int Y_startcol, int Y_ncols, Mat &result, int startrow=0, int nrows=-1, int ignore_this_row=-1) const |
virtual void | accumulateXtX (int X_startcol, int X_ncols, Mat &result, int startrow=0, int nrows=-1, int ignore_this_row=-1) const |
virtual void | evaluateSumOfFprop (Func f, Vec &output_result, int nsamples=-1) |
compute fprop or fbprop of a sumOf operation | |
virtual void | evaluateSumOfFbprop (Func f, Vec &output_result, Vec &output_gradient, int nsamples=-1) |
Static Public Member Functions | |
void | declareOptions (OptionList &ol) |
redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down) | |
Protected Attributes | |
VMat | vm |
Private Types | |
typedef VMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 55 of file ForwardVMatrix.h.
|
Reimplemented from PLearn::VMatrix. Reimplemented in PLearn::AutoVMatrix. Definition at line 57 of file ForwardVMatrix.h. |
|
Definition at line 55 of file ForwardVMatrix.cc. |
|
Definition at line 58 of file ForwardVMatrix.cc. |
|
A special case of method accumulateXtY result += transpose(X).X Where X = this->subMatColumns(X_startcol,X_ncols) Reimplemented from PLearn::VMatrix. Definition at line 274 of file ForwardVMatrix.cc. References vm. |
|
result += transpose(X).Y Where X = this->subMatColumns(X_startcol,X_ncols) and Y = this->subMatColumns(Y_startcol,Y_ncols); Reimplemented from PLearn::VMatrix. Definition at line 269 of file ForwardVMatrix.cc. References vm. |
|
This method must be implemented for matrices that are allowed to grow.
Reimplemented from PLearn::VMatrix. Definition at line 176 of file ForwardVMatrix.cc. References vm. |
|
Should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object. Reimplemented from PLearn::VMatrix. Reimplemented in PLearn::AutoVMatrix. Definition at line 64 of file ForwardVMatrix.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::VMatrix. Reimplemented in PLearn::AutoVMatrix. Definition at line 71 of file ForwardVMatrix.cc. References PLearn::VMatrix::hasFieldInfos(), PLearn::VMat::length(), vm, PLearn::VMatrix::width(), and PLearn::VMat::width(). |
|
The default implementation of this method does nothing But subclasses may overload it to reallocate memory to exactly what is needed and no more.
Reimplemented from PLearn::VMatrix. Definition at line 199 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 148 of file ForwardVMatrix.cc. References vm. |
|
redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down) ex: static void declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "the size of the input\n it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "the learnt model weights"); inherited::declareOptions(ol); } Reimplemented from PLearn::VMatrix. Reimplemented in PLearn::AutoVMatrix. Definition at line 108 of file ForwardVMatrix.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
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::VMatrix. Definition at line 222 of file ForwardVMatrix.cc. References vm. |
|
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::VMatrix. Definition at line 218 of file ForwardVMatrix.cc. References vm. |
|
This will compute for this vmat m a result vector (whose length must be tha same as m's) s.t. result[i] = ker( m(i).subVec(v1_startcol,v1_ncols) , v2) i.e. the kernel value betweeen each (sub)row of m and v2 Reimplemented from PLearn::VMatrix. Definition at line 235 of file ForwardVMatrix.cc. References vm. |
|
same as evaluateKernelTopN but will look for the N smallest values instead of top values. results are sorted with smallest kernel value first Reimplemented from PLearn::VMatrix. Definition at line 265 of file ForwardVMatrix.cc. References vm. |
|
returns sum_i [ ker( m(i).subVec(v1_startcol,v1_ncols) , v2) ]
Reimplemented from PLearn::VMatrix. Definition at line 241 of file ForwardVMatrix.cc. References vm. |
|
This will return the Top N kernel evaluated values (between vmat (sub)rows and v2) and their associated row_index. Result is returned as a vector of length N of pairs (kernel_value,row_index) Results are sorted with largest kernel value first Reimplemented from PLearn::VMatrix. Definition at line 258 of file ForwardVMatrix.cc. References vm. |
|
targetsum := sum_i [ m(i).subVec(t_startcol,t_ncols) * ker( m(i).subVec(v1_startcol,v1_ncols) , v2) ] and returns sum_i [ ker( m(i).subVec(v1_startcol,v1_ncols) , v2) ]
Reimplemented from PLearn::VMatrix. Definition at line 248 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 283 of file ForwardVMatrix.cc. References vm. |
|
compute fprop or fbprop of a sumOf operation
Reimplemented from PLearn::VMatrix. Definition at line 280 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 183 of file ForwardVMatrix.cc. References vm. |
|
returns element (i,j)
Reimplemented from PLearn::VMatrix. Definition at line 163 of file ForwardVMatrix.cc. References vm. |
|
copies column i into v (which must have appropriate length equal to the VMat's length)
Reimplemented from PLearn::VMatrix. Definition at line 191 of file ForwardVMatrix.cc. References PLearn::VMat::getColumn(), and vm. |
|
copies the submatrix starting at i,j into m (which must have appropriate length and width)
Reimplemented from PLearn::VMatrix. Definition at line 185 of file ForwardVMatrix.cc. References PLearn::Mat, and vm. |
|
returns the value->string mapping for field 'fld'
Reimplemented from PLearn::VMatrix. Definition at line 144 of file ForwardVMatrix.cc. References vm. |
|
Assigns the value of the Vars in the list (the total size of all the vars in the list must equal width() ).
Reimplemented from PLearn::VMatrix. Definition at line 227 of file ForwardVMatrix.cc. References vm. |
|
copies row i into v (which must have appropriate length equal to the VMat's width)
Reimplemented from PLearn::VMatrix. Definition at line 179 of file ForwardVMatrix.cc. References vm. |
|
returns element as a string, even if its a number (which is always the case unless class is StrTableVMatrix
Reimplemented from PLearn::VMatrix. Definition at line 122 of file ForwardVMatrix.cc. References vm. |
|
returns the whole string->value mapping
Definition at line 125 of file ForwardVMatrix.cc. References PLERROR. |
|
returns the string->value mapping for field 'fld'
Reimplemented from PLearn::VMatrix. Definition at line 137 of file ForwardVMatrix.cc. References vm. |
|
return value associated with a string. Default returns NaN
Reimplemented from PLearn::VMatrix. Definition at line 118 of file ForwardVMatrix.cc. References vm. |
|
fills v with the subrow i lying between columns j (inclusive) and j+v.length() (exclusive)
Reimplemented from PLearn::VMatrix. Definition at line 170 of file ForwardVMatrix.cc. References PLearn::VMat::getSubRow(), PLearn::Vec, and vm. |
|
returns the string associated with value val for field# col. Or returns "" if no string is associated. Reimplemented from PLearn::VMatrix. Definition at line 114 of file ForwardVMatrix.cc. |
|
Reimplemented from PLearn::VMatrix. Reimplemented in PLearn::AutoVMatrix. Definition at line 286 of file ForwardVMatrix.cc. References PLearn::deepCopyField(), and vm. |
|
DEPRECATED For backward compatibility with old saved object.
Reimplemented from PLearn::VMatrix. Definition at line 232 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 230 of file ForwardVMatrix.cc. References vm. |
|
|
|
sets element (i,j) to value
Reimplemented from PLearn::VMatrix. Definition at line 167 of file ForwardVMatrix.cc. References vm. |
|
copies matrix m at position i,j of this VMat
Reimplemented from PLearn::VMatrix. Definition at line 187 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 181 of file ForwardVMatrix.cc. References vm. |
|
It is suggested that this method be implemented in subclasses of writable matrices to speed up accesses (default version repeatedly calls put(i,j,value) which may have a significant overhead) Reimplemented from PLearn::VMatrix. Definition at line 173 of file ForwardVMatrix.cc. References vm. |
|
in case the dimensions of an underlying vmat has changed, recompute it
Reimplemented from PLearn::VMatrix. Definition at line 203 of file ForwardVMatrix.cc. References PLearn::VMat::length(), vm, and PLearn::VMat::width(). |
|
returns the cooccurence statistics conditioned on the given field (within the ranges returned by getRanges() ) The results are cached in file stats#.psave (where # stands for the condfield index)
Reimplemented from PLearn::VMatrix. Definition at line 152 of file ForwardVMatrix.cc. References PLearn::VMat::save(), and vm. |
|
Definition at line 159 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 157 of file ForwardVMatrix.cc. References vm. |
|
Reimplemented from PLearn::VMatrix. Definition at line 155 of file ForwardVMatrix.cc. References vm. |
|
This allows to set the underlying vmat.
Definition at line 98 of file ForwardVMatrix.cc. |
|
default version returns a SubVMatrix referencing the current VMatrix however this can be overridden to provide more efficient shortcuts (see MemoryVMatrix::subMat and SubVMatrix::subMat for examples) Reimplemented from PLearn::VMatrix. Definition at line 215 of file ForwardVMatrix.cc. References PLearn::VMat::subMat(), and vm. |
|
returns a Mat with the same data as this VMat The default version of this method copies the data in a fresh Mat created in memory However this method will typically be overrided by subclasses (such as MemoryVMatrix) whose internal representation is already a Mat in order to return this Mat directly to avoid a new memory allocation and copy of elements. In this case, and in this case only, modifying the elements of the returned Mat will logically result in modified elements in the original VMatrix view of it. Reimplemented from PLearn::VMatrix. Definition at line 194 of file ForwardVMatrix.cc. References PLearn::VMat::toMat(), and vm. |
|