#include <ReconstructionWeightsKernel.h>
Inheritance diagram for PLearn::ReconstructionWeightsKernel:
Public Member Functions | |
ReconstructionWeightsKernel () | |
Default constructor. | |
virtual void | build () |
Simply calls inherited::build() then build_(). | |
virtual void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
Transforms a shallow copy into a deep copy. | |
PLEARN_DECLARE_OBJECT (ReconstructionWeightsKernel) | |
virtual real | evaluate (const Vec &x1, const Vec &x2) const |
Compute K(x1,x2). | |
virtual real | evaluate_i_j (int i, int j) const |
returns evaluate(data(i),data(j)) | |
virtual real | evaluate_i_x (int i, const Vec &x, real squared_norm_of_x=-1) const |
virtual real | evaluate_x_i (const Vec &x, int i, real squared_norm_of_x=-1) const |
returns evaluate(x,data(i)) [default version calls evaluate_i_x if kernel is_symmetric] | |
virtual real | evaluate_x_i_again (const Vec &x, int i, real squared_norm_of_x=-1, bool first_time=false) const |
virtual void | setDataForKernelMatrix (VMat the_data) |
** Subclasses may overload these methods to provide efficient kernel matrix access ** | |
virtual real | evaluate_sum_k_i_k_j (int i, int j) const |
Return sum_k K(x_k, x_i) * K(x_k, x_j). | |
virtual void | computeLLEMatrix (const Mat &lle_mat) const |
Fill 'lle_mat', which must be of size (n x n), with entries (i,j) equal to W_{ij} + W_{ji} - W_{ki} W_{kj} (this is used in LLE to compute the kernel Gram matrix). | |
Public Attributes | |
Ker | distance_kernel |
Ker | dot_product_kernel |
int | ignore_nearest |
int | knn |
real | regularizer |
Protected Member Functions | |
void | computeWeights () |
Precompute the weights W_{ij}. | |
void | reconstruct (const Vec &x, const TVec< int > &neighbors, Vec &w) const |
Compute the reconstruction weights for a vector, given its nearest neighbors. | |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Protected Attributes | |
Ker | dist_ker |
The kernel used to compute distances (equal to 'distance_kernel' if specified, and otherwise the usual Euclidean distance). | |
Ker | dp_ker |
The kernel used to compute dot products (equal to 'dot_product_kernel' if specified, and otherwise the usual DotProductKernel). | |
TMat< int > | neighbors |
The indices of the neighbors of each data point. | |
TVec< TMat< int > > | is_neighbor_of |
The element i is a matrix whose first column is the list of the points which have i among their neighbors, and the second column is the index of i in these neighbors. | |
PP< SelectRowsVMatrix > | sub_data |
Points toward a subset of the training data (typically, a neighborhood). | |
Mat | weights |
The matrix with the weights W_{ij}. | |
Private Types | |
typedef Kernel | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
Private Attributes | |
bool | build_in_progress |
True iff build() has been called but build_() has not been called yet. | |
bool | new_data |
True iff the 'setDataForKernelMatrix' method has been called since last time we called 'reconstruct'. | |
Mat | k_xi_x_sorted |
Used in 'evaluate_x_i_again' to store the distances from x to its nearest neighbors. | |
TVec< int > | neighbors_of_x |
Used in 'evaluate_x_i_again' to store the neighbors of x. | |
Vec | weights_x |
Used in 'evaluate_x_i_again' to store the reconstruction weights of x. | |
Mat | local_gram |
Used in 'reconstruct' to store the local Gram matrix. | |
PP< ShiftAndRescaleVMatrix > | centered_neighborhood |
Used in 'reconstruct' to point toward the locally centered data. | |
Vec | ones |
Used in 'reconstruct' to store a vector filled with 1. |
|
Reimplemented from PLearn::Kernel. Definition at line 59 of file ReconstructionWeightsKernel.h. |
|
Default constructor.
Definition at line 55 of file ReconstructionWeightsKernel.cc. References sub_data. |
|
Simply calls inherited::build() then build_().
Reimplemented from PLearn::Kernel. Definition at line 112 of file ReconstructionWeightsKernel.cc. References build_(), and build_in_progress. |
|
This does the actual building.
Reimplemented from PLearn::Kernel. Definition at line 122 of file ReconstructionWeightsKernel.cc. References build_in_progress, dist_ker, distance_kernel, dot_product_kernel, dp_ker, ignore_nearest, knn, PLERROR, and setDataForKernelMatrix(). Referenced by build(). |
|
Fill 'lle_mat', which must be of size (n x n), with entries (i,j) equal to W_{ij} + W_{ji} - W_{ki} W_{kj} (this is used in LLE to compute the kernel Gram matrix).
Definition at line 151 of file ReconstructionWeightsKernel.cc. References PLearn::TMat< T >::clear(), k, knn, PLearn::TMat< T >::length(), PLearn::Mat, neighbors, PLERROR, PLearn::ProgressBar::update(), weights, and PLearn::TMat< T >::width(). |
|
Precompute the weights W_{ij}.
Definition at line 181 of file ReconstructionWeightsKernel.cc. References dist_ker, PLearn::VMat::getSubRow(), ignore_nearest, is_neighbor_of, knn, PLearn::Mat, neighbors, PLERROR, reconstruct(), PLearn::TVec< TMat< int > >::resize(), PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), PLearn::sortRows(), PLearn::ProgressBar::update(), PLearn::Vec, and weights. Referenced by setDataForKernelMatrix(). |
|
Declares this class' options.
Reimplemented from PLearn::Kernel. Definition at line 83 of file ReconstructionWeightsKernel.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
Compute K(x1,x2).
Implements PLearn::Kernel. Definition at line 229 of file ReconstructionWeightsKernel.cc. References evaluate_x_i(). |
|
returns evaluate(data(i),data(j))
Reimplemented from PLearn::Kernel. Definition at line 243 of file ReconstructionWeightsKernel.cc. References ignore_nearest, k, knn, neighbors, PLERROR, weights, and PLearn::TMat< T >::width(). Referenced by evaluate_i_x(). |
|
returns evaluate(data(i),x) [squared_norm_of_x is just a hint that may allow to speed up computation if it is already known, but it's optional] Reimplemented from PLearn::Kernel. Definition at line 270 of file ReconstructionWeightsKernel.cc. References evaluate_i_j(), and x. |
|
Return sum_k K(x_k, x_i) * K(x_k, x_j).
Definition at line 281 of file ReconstructionWeightsKernel.cc. References ignore_nearest, is_neighbor_of, knn, PLearn::TMat< T >::length(), PLERROR, PLearn::sum(), weights, and PLearn::TMat< T >::width(). |
|
returns evaluate(x,data(i)) [default version calls evaluate_i_x if kernel is_symmetric]
Reimplemented from PLearn::Kernel. Definition at line 319 of file ReconstructionWeightsKernel.cc. References evaluate_x_i_again(), and x. Referenced by evaluate(). |
|
Reimplemented from PLearn::Kernel. Definition at line 326 of file ReconstructionWeightsKernel.cc. References dist_ker, PLearn::TVec< int >::find(), ignore_nearest, k_xi_x_sorted, knn, neighbors_of_x, reconstruct(), PLearn::TVec< int >::resize(), PLearn::TMat< T >::subMat(), weights_x, and x. Referenced by evaluate_x_i(). |
|
Transforms a shallow copy into a deep copy.
Definition at line 345 of file ReconstructionWeightsKernel.cc. References PLERROR. |
|
|
|
Compute the reconstruction weights for a vector, given its nearest neighbors.
Definition at line 362 of file ReconstructionWeightsKernel.cc. References centered_neighborhood, dp_ker, PLearn::TVec< T >::fill(), PLearn::TVec< T >::length(), local_gram, new_data, ones, PLearn::regularizeMatrix(), regularizer, PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), PLearn::solveLinearSystem(), sub_data, PLearn::sum(), weights_x, and x. Referenced by computeWeights(), and evaluate_x_i_again(). |
|
** Subclasses may overload these methods to provide efficient kernel matrix access ** This method sets the data VMat that will be used to define the kernel matrix. It may precompute values from this that may later accelerate the evaluation of a kernel matrix element Reimplemented from PLearn::Kernel. Definition at line 405 of file ReconstructionWeightsKernel.cc. References build_in_progress, computeWeights(), dist_ker, new_data, and sub_data. Referenced by build_(). |
|
True iff build() has been called but build_() has not been called yet.
Definition at line 62 of file ReconstructionWeightsKernel.h. Referenced by build(), build_(), and setDataForKernelMatrix(). |
|
Used in 'reconstruct' to point toward the locally centered data.
Definition at line 83 of file ReconstructionWeightsKernel.h. Referenced by reconstruct(). |
|
The kernel used to compute distances (equal to 'distance_kernel' if specified, and otherwise the usual Euclidean distance).
Definition at line 98 of file ReconstructionWeightsKernel.h. Referenced by build_(), computeWeights(), evaluate_x_i_again(), and setDataForKernelMatrix(). |
|
Definition at line 125 of file ReconstructionWeightsKernel.h. Referenced by build_(). |
|
Definition at line 126 of file ReconstructionWeightsKernel.h. Referenced by build_(). |
|
The kernel used to compute dot products (equal to 'dot_product_kernel' if specified, and otherwise the usual DotProductKernel).
Definition at line 102 of file ReconstructionWeightsKernel.h. Referenced by build_(), and reconstruct(). |
|
Definition at line 127 of file ReconstructionWeightsKernel.h. Referenced by build_(), computeWeights(), evaluate_i_j(), evaluate_sum_k_i_k_j(), and evaluate_x_i_again(). |
|
The element i is a matrix whose first column is the list of the points which have i among their neighbors, and the second column is the index of i in these neighbors. The first column is sorted by increasing index, and does not contain i. Definition at line 111 of file ReconstructionWeightsKernel.h. Referenced by computeWeights(), and evaluate_sum_k_i_k_j(). |
|
Used in 'evaluate_x_i_again' to store the distances from x to its nearest neighbors.
Definition at line 71 of file ReconstructionWeightsKernel.h. Referenced by evaluate_x_i_again(). |
|
Definition at line 128 of file ReconstructionWeightsKernel.h. Referenced by build_(), computeLLEMatrix(), computeWeights(), evaluate_i_j(), evaluate_sum_k_i_k_j(), and evaluate_x_i_again(). |
|
Used in 'reconstruct' to store the local Gram matrix.
Definition at line 80 of file ReconstructionWeightsKernel.h. Referenced by reconstruct(). |
|
The indices of the neighbors of each data point.
Definition at line 105 of file ReconstructionWeightsKernel.h. Referenced by computeLLEMatrix(), computeWeights(), and evaluate_i_j(). |
|
Used in 'evaluate_x_i_again' to store the neighbors of x.
Definition at line 74 of file ReconstructionWeightsKernel.h. Referenced by evaluate_x_i_again(). |
|
True iff the 'setDataForKernelMatrix' method has been called since last time we called 'reconstruct'. This is necessary to ensure everything is correctly initialized in the 'reconstruct' method. Definition at line 67 of file ReconstructionWeightsKernel.h. Referenced by reconstruct(), and setDataForKernelMatrix(). |
|
Used in 'reconstruct' to store a vector filled with 1.
Definition at line 86 of file ReconstructionWeightsKernel.h. Referenced by reconstruct(). |
|
Definition at line 129 of file ReconstructionWeightsKernel.h. Referenced by reconstruct(). |
|
Points toward a subset of the training data (typically, a neighborhood).
Definition at line 114 of file ReconstructionWeightsKernel.h. Referenced by reconstruct(), ReconstructionWeightsKernel(), and setDataForKernelMatrix(). |
|
The matrix with the weights W_{ij}.
Definition at line 117 of file ReconstructionWeightsKernel.h. Referenced by computeLLEMatrix(), computeWeights(), evaluate_i_j(), and evaluate_sum_k_i_k_j(). |
|
Used in 'evaluate_x_i_again' to store the reconstruction weights of x.
Definition at line 77 of file ReconstructionWeightsKernel.h. Referenced by evaluate_x_i_again(), and reconstruct(). |