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

#include <ReconstructionWeightsKernel.h>

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

List of all members.

Public Member Functions

 ReconstructionWeightsKernel ()
 Default constructor.
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
ReconstructionWeightsKernel
deepCopy (CopiesMap &copies) const
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
 Return evaluate(data(i),x).
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 override 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} - \sum_k W_{ki} W_{kj} $ (this is used in LLE to compute the kernel Gram matrix).

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

Public Attributes

Ker distance_kernel
Ker dot_product_kernel
int ignore_nearest
int knn
real regularizer

Static Public Attributes

static StaticInitializer _static_initializer_

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

static 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< intneighbors
 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< SelectRowsVMatrixsub_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< intneighbors_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< ShiftAndRescaleVMatrixcentered_neighborhood
 Used in 'reconstruct' to point toward the locally centered data.
Vec ones
 Used in 'reconstruct' to store a vector filled with 1.

Detailed Description

Definition at line 54 of file ReconstructionWeightsKernel.h.


Member Typedef Documentation

Reimplemented from PLearn::Kernel.

Definition at line 59 of file ReconstructionWeightsKernel.h.


Constructor & Destructor Documentation

PLearn::ReconstructionWeightsKernel::ReconstructionWeightsKernel ( )

Default constructor.

Definition at line 55 of file ReconstructionWeightsKernel.cc.

References PLearn::Kernel::is_symmetric, and sub_data.

    : build_in_progress(false),
      new_data(true),
      ignore_nearest(1),
      knn(5),
      regularizer(1e-6)
{
    is_symmetric = false;
    sub_data = new SelectRowsVMatrix();
}

Member Function Documentation

string PLearn::ReconstructionWeightsKernel::_classname_ ( ) [static]

Reimplemented from PLearn::Kernel.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

OptionList & PLearn::ReconstructionWeightsKernel::_getOptionList_ ( ) [static]

Reimplemented from PLearn::Kernel.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

RemoteMethodMap & PLearn::ReconstructionWeightsKernel::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::Kernel.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

Object * PLearn::ReconstructionWeightsKernel::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

StaticInitializer ReconstructionWeightsKernel::_static_initializer_ & PLearn::ReconstructionWeightsKernel::_static_initialize_ ( ) [static]

Reimplemented from PLearn::Kernel.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

void PLearn::ReconstructionWeightsKernel::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::Kernel.

Definition at line 112 of file ReconstructionWeightsKernel.cc.

References PLearn::Kernel::build(), build_(), and build_in_progress.

Here is the call graph for this function:

void PLearn::ReconstructionWeightsKernel::build_ ( ) [private]

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, PLearn::Kernel::report_progress, setDataForKernelMatrix(), and PLearn::Kernel::specify_dataset.

Referenced by build().

{
    if (distance_kernel) {
        dist_ker = distance_kernel;
    } else {
        dist_ker = new DistanceKernel(2);
        dist_ker->report_progress = this->report_progress;
    }

    if (dot_product_kernel) {
        dp_ker = dot_product_kernel;
    } else {
        dp_ker = new DotProductKernel();
        dp_ker->build();
    }
    // Safety check.
    if (ignore_nearest > knn)
        PLERROR("In ReconstructionWeightsKernel::build_ - You can't ignore more than 'knn' neighbors");
    build_in_progress = false;
    // This code, normally executed in Kernel::build_, can only be executed
    // now beause the kernels 'dist_ker' and 'dp_ker' have to be initialized.
    if (specify_dataset) {
        this->setDataForKernelMatrix(specify_dataset);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string PLearn::ReconstructionWeightsKernel::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

void PLearn::ReconstructionWeightsKernel::computeLLEMatrix ( const Mat lle_mat) const [virtual]

Fill 'lle_mat', which must be of size (n x n), with entries (i,j) equal to $ W_{ij} + W_{ji} - \sum_k 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(), i, j, knn, PLearn::TMat< T >::length(), PLearn::Kernel::n_examples, neighbors, PLERROR, PLearn::Kernel::report_progress, weights, and PLearn::TMat< T >::width().

                                                                           {
    if (lle_mat.length() != n_examples || lle_mat.width() != n_examples)
        PLERROR("In ReconstructionWeightsKernel::computeLLEMatrix - Wrong size for 'lle_mat'");
    lle_mat.clear();
    PP<ProgressBar> pb;
    if (report_progress)
        pb = new ProgressBar("Computing LLE matrix", n_examples);
    int neighb_j, neighb_k;
    real w_ij;
    for (int i = 0; i < n_examples; i++) {
        for (int j = 0; j < knn - 1; j++) {
            neighb_j = neighbors(i, j + 1);
            w_ij = weights(i, j);
            lle_mat(i, neighb_j) += w_ij;
            lle_mat(neighb_j, i) += w_ij;
            for (int k = 0; k < knn - 1; k++) {
                neighb_k = neighbors(i, k + 1);
                lle_mat(neighb_j, neighb_k) -= w_ij * weights(i, k);
            }
        }
        if (report_progress)
            pb->update(i + 1);
    }
}

Here is the call graph for this function:

void PLearn::ReconstructionWeightsKernel::computeWeights ( ) [protected]

Precompute the weights W_{ij}.

Definition at line 179 of file ReconstructionWeightsKernel.cc.

References PLearn::Kernel::computeKNNeighbourMatrixFromDistanceMatrix(), PLearn::Kernel::data, PLearn::Kernel::data_inputsize, dist_ker, PLearn::VMat::getSubRow(), i, ignore_nearest, is_neighbor_of, j, knn, PLearn::Kernel::n_examples, neighbors, PLERROR, reconstruct(), PLearn::Kernel::report_progress, PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), PLearn::sortRows(), and weights.

Referenced by setDataForKernelMatrix().

                                                 {
    static Vec point_i;
    static Vec weights_i;
    if (!data)
        PLERROR("In ReconstructionWeightsKernel::computeWeights - Can only be called if 'data' has been set");
    point_i.resize(data_inputsize);
    weights.resize(n_examples, knn - ignore_nearest); // Allocate memory for the weights.
    // First compute the nearest neighbors.
    Mat distances(n_examples, n_examples);
    dist_ker->computeGramMatrix(distances);
    neighbors =
        computeKNNeighbourMatrixFromDistanceMatrix(distances, knn, true,
                                                                                                   report_progress != 0);
    distances = Mat(); // Free memory.
    // Fill the 'is_neighbor_of' vector.
    is_neighbor_of.resize(n_examples);
    TVec<int> row(2);
    for (int i = 0; i < n_examples; i++)
        is_neighbor_of[i].resize(0, 2);
    for (int i = 0; i < n_examples; i++) {
        row[0] = i;
        for (int j = ignore_nearest; j < knn; j++) {
            row[1] = j;
            is_neighbor_of[neighbors(i,j)].appendRow(row);
        }
    }
    for (int i = 0; i < n_examples; i++)
        sortRows(is_neighbor_of[i]);
    // Then compute the weights for each point i.
    TVec<int> neighbors_of_i;
    PP<ProgressBar> pb;
    if (report_progress)
        pb = new ProgressBar("Computing reconstruction weights", n_examples);
    for (int i = 0; i < n_examples; i++) {
        // Isolate the neighbors.
        neighbors_of_i = neighbors(i).subVec(ignore_nearest, knn - ignore_nearest);
        weights_i = weights(i);
        data->getSubRow(i, 0, point_i);
        reconstruct(point_i, neighbors_of_i, weights_i);
        if (report_progress)
            pb->update(i+1);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::ReconstructionWeightsKernel::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::Kernel.

Definition at line 83 of file ReconstructionWeightsKernel.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Kernel::declareOptions(), distance_kernel, dot_product_kernel, ignore_nearest, knn, and regularizer.

{
    // Build options.

    declareOption(ol, "knn", &ReconstructionWeightsKernel::knn, OptionBase::buildoption,
                  "The number of nearest neighbors considered (including the point itself).");

    declareOption(ol, "regularizer", &ReconstructionWeightsKernel::regularizer, OptionBase::buildoption,
                  "A factor multiplied by the trace of the local Gram matrix and added to\n"
                  "the diagonal to ensure stability when solving the linear system.");

    declareOption(ol, "ignore_nearest", &ReconstructionWeightsKernel::ignore_nearest, OptionBase::buildoption,
                  "The number of nearest neighbors to ignore when computing the reconstruction weights.");

    declareOption(ol, "distance_kernel", &ReconstructionWeightsKernel::distance_kernel, OptionBase::buildoption,
                  "The kernel used to compute the distances.\n"
                  "If not specified, then the usual Euclidean distance will be used.");

    declareOption(ol, "dot_product_kernel", &ReconstructionWeightsKernel::dot_product_kernel, OptionBase::buildoption,
                  "The kernel used to compute dot products in the neighborhood of each data point.\n"
                  "If not specified, then the usual Euclidean dot product will be used.");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Kernel.

Definition at line 165 of file ReconstructionWeightsKernel.h.

:

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

Reimplemented from PLearn::Kernel.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

real PLearn::ReconstructionWeightsKernel::evaluate ( const Vec x1,
const Vec x2 
) const [virtual]

Compute K(x1,x2).

Implements PLearn::Kernel.

Definition at line 226 of file ReconstructionWeightsKernel.cc.

References evaluate_x_i(), PLearn::Kernel::isInData(), and j.

                                                                             {
    static int j;
    if (isInData(x2, &j)) {
        // x2 is in the training set, thus it makes sense to use it in the reconstruction.
        return evaluate_x_i(x1, j);
    } else {
        // x2 is not in the training set, thus its weight is 0.
        return 0;
    }
}

Here is the call graph for this function:

real PLearn::ReconstructionWeightsKernel::evaluate_i_j ( int  i,
int  j 
) const [virtual]

returns evaluate(data(i),data(j))

Reimplemented from PLearn::Kernel.

Definition at line 240 of file ReconstructionWeightsKernel.cc.

References ignore_nearest, knn, neighbors, PLERROR, weights, and PLearn::TMat< T >::width().

Referenced by evaluate_i_x().

                                                                 {
    static TVec<int> neighbors_of_i;
    if (ignore_nearest == 0) {
        // We do not ignore the nearest neighbor, which is i itself. Thus the
        // weight is \delta_{ij}, since i is reconstructed exactly by itself.
        if (i == j)
            return 1.0;
        else
            return 0;
    } else {
#ifdef BOUNDCHECK
        if (ignore_nearest != knn - weights.width())
            PLERROR("In ReconstructionWeightsKernel::evaluate_i_j - You must recompute the weights after modifying the 'ignore_nearest' option");
#endif
        neighbors_of_i = neighbors(i);
        for (int k = ignore_nearest; k < knn; k++) {
            if (neighbors_of_i[k] == j) {
                return weights(i, k - ignore_nearest);
            }
        }
        return 0;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

real PLearn::ReconstructionWeightsKernel::evaluate_i_x ( int  i,
const Vec x,
real  squared_norm_of_x = -1 
) const [virtual]

Return 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 267 of file ReconstructionWeightsKernel.cc.

References evaluate_i_j(), PLearn::Kernel::isInData(), and j.

                                                                                                {
    static int j;
    if (isInData(x, &j))
        return evaluate_i_j(i,j);
    else
        return 0;
}

Here is the call graph for this function:

real PLearn::ReconstructionWeightsKernel::evaluate_sum_k_i_k_j ( int  i,
int  j 
) const [virtual]

Return sum_k K(x_k, x_i) * K(x_k, x_j).

Definition at line 278 of file ReconstructionWeightsKernel.cc.

References i, ignore_nearest, is_neighbor_of, j, knn, PLearn::TMat< T >::length(), PLERROR, PLearn::sum(), weights, and PLearn::TMat< T >::width().

                                                                         {
    static TMat<int> i_is_neighb_of, j_is_neighb_of;
    i_is_neighb_of = is_neighbor_of[i];
    j_is_neighb_of = is_neighbor_of[j];
    int test_n;
    int k_i = 0;
    int k_j = 0;
    real sum = 0;
    // Safety check
    if (ignore_nearest != knn - weights.width())
        PLERROR("In ReconstructionWeightsKernel::evaluate_sum_k_i_k_j - You must recompute the weights after modifying 'ignore_nearest'");
    while (k_i < i_is_neighb_of.length()) {
        test_n = i_is_neighb_of(k_i, 0);
        while (k_j < j_is_neighb_of.length() && test_n > j_is_neighb_of(k_j, 0))
            k_j++;
        if (k_j < j_is_neighb_of.length()) {
            if (test_n == j_is_neighb_of(k_j, 0)) {
                // Found a common k.
                sum += weights(test_n, i_is_neighb_of(k_i, 1) - ignore_nearest) * weights(test_n, j_is_neighb_of(k_j, 1) - ignore_nearest);
                k_i++;
                k_j++;
            } else {
                // Increase k_i.
                test_n = j_is_neighb_of(k_j, 0);
                while (k_i < i_is_neighb_of.length() && test_n > i_is_neighb_of(k_i, 0))
                    k_i++;
            }
        } else {
            // No more common point.
            return sum;
        }
    }
    return sum;
}

Here is the call graph for this function:

real PLearn::ReconstructionWeightsKernel::evaluate_x_i ( const Vec x,
int  i,
real  squared_norm_of_x = -1 
) const [virtual]

returns evaluate(x,data(i)) [default version calls evaluate_i_x if kernel is_symmetric]

Reimplemented from PLearn::Kernel.

Definition at line 316 of file ReconstructionWeightsKernel.cc.

References evaluate_x_i_again().

Referenced by evaluate().

                                                                                                {
    return evaluate_x_i_again(x, i, squared_norm_of_x, true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

real PLearn::ReconstructionWeightsKernel::evaluate_x_i_again ( const Vec x,
int  i,
real  squared_norm_of_x = -1,
bool  first_time = false 
) const [virtual]

Reimplemented from PLearn::Kernel.

Definition at line 323 of file ReconstructionWeightsKernel.cc.

References dist_ker, PLearn::TVec< T >::find(), ignore_nearest, k_xi_x_sorted, knn, neighbors_of_x, reconstruct(), PLearn::TVec< T >::resize(), PLearn::TMat< T >::subMat(), and weights_x.

Referenced by evaluate_x_i().

                                                                                                                       {
    if (first_time) {
        neighbors_of_x.resize(knn);
        // Find nearest neighbors of x.
        dist_ker->computeNearestNeighbors(x, k_xi_x_sorted, knn);
        neighbors_of_x << k_xi_x_sorted.subMat(ignore_nearest, 1, knn, 1);
        // Find reconstruction weights.
        reconstruct(x, neighbors_of_x, weights_x);
    }
    int n_j = neighbors_of_x.find(i);
    if (n_j == -1)
        // The point i is not a neighbor of x.
        return 0;
    return weights_x[n_j];
}

Here is the call graph for this function:

Here is the caller graph for this function:

OptionList & PLearn::ReconstructionWeightsKernel::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

OptionMap & PLearn::ReconstructionWeightsKernel::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

RemoteMethodMap & PLearn::ReconstructionWeightsKernel::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 78 of file ReconstructionWeightsKernel.cc.

void PLearn::ReconstructionWeightsKernel::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Kernel.

Definition at line 342 of file ReconstructionWeightsKernel.cc.

References PLearn::Kernel::makeDeepCopyFromShallowCopy(), and PLERROR.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### Call deepCopyField on all "pointer-like" fields 
    // ### that you wish to be deepCopied rather than 
    // ### shallow-copied.
    // ### ex:
    // deepCopyField(trainvec, copies);

    // ### Remove this line when you have fully implemented this method.
    PLERROR("ReconstructionWeightsKernel::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

void PLearn::ReconstructionWeightsKernel::reconstruct ( const Vec x,
const TVec< int > &  neighbors,
Vec w 
) const [protected]

Compute the reconstruction weights for a vector, given its nearest neighbors.

Definition at line 359 of file ReconstructionWeightsKernel.cc.

References centered_neighborhood, dp_ker, PLearn::TVec< T >::fill(), PLearn::TVec< T >::length(), local_gram, neighbors, 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().

                                                                                                    {
    static bool need_init;
    need_init = new_data;
    int k_neighb = neighbors.length();
    if (ones.length() != k_neighb) {
        // 'ones' does not have the right size.
        need_init = true;
        ones.resize(k_neighb);
        ones.fill(1);
    }
    w.resize(k_neighb);
    if (need_init) {
        // This is the first execution.
        local_gram.resize(k_neighb, k_neighb);
        centered_neighborhood = new ShiftAndRescaleVMatrix();
        centered_neighborhood->no_scale = true;
        centered_neighborhood->negate_shift = true;
        centered_neighborhood->automatic = false;
        centered_neighborhood->source = (SelectRowsVMatrix*) sub_data;
        new_data = false;
    }
    // Center data on x.
    sub_data->indices = neighbors;
    sub_data->build();
    centered_neighborhood->shift = x;
    centered_neighborhood->build();
    // TODO Get rid of this expensive build.
    // Compute the local Gram matrix.
    dp_ker->setDataForKernelMatrix((ShiftAndRescaleVMatrix*) centered_neighborhood);
    dp_ker->computeGramMatrix(local_gram);
    // Add regularization on the diagonal.
    regularizeMatrix(local_gram, regularizer);
    // Solve linear system.
    Vec weights_x = solveLinearSystem(local_gram, ones);
    // TODO Avoid the copy of the weights.
    w << weights_x;
    // Ensure the sum of weights is 1 to get final solution.
    w /= sum(w);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::ReconstructionWeightsKernel::setDataForKernelMatrix ( VMat  the_data) [virtual]

** Subclasses may override 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 402 of file ReconstructionWeightsKernel.cc.

References build_in_progress, computeWeights(), dist_ker, new_data, PLearn::Kernel::setDataForKernelMatrix(), and sub_data.

Referenced by build_().

                                                                      {
    if (build_in_progress)
        return;
    inherited::setDataForKernelMatrix(the_data);
    dist_ker->setDataForKernelMatrix(the_data);
    sub_data->source = the_data;
    new_data = true;
    computeWeights();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from PLearn::Kernel.

Definition at line 165 of file ReconstructionWeightsKernel.h.

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

Definition at line 126 of file ReconstructionWeightsKernel.h.

Referenced by build_(), and declareOptions().

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

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

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(), evaluate_i_j(), and reconstruct().

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 declareOptions(), and 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().


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