#include <GeodesicDistanceKernel.h>
Inheritance diagram for PLearn::GeodesicDistanceKernel:
Public Member Functions | |
GeodesicDistanceKernel () | |
Default constructor. | |
GeodesicDistanceKernel (Ker the_distance_kernel, int the_knn=10, string the_geodesic_file="", bool the_pow_distance=false) | |
Convenient 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 (GeodesicDistanceKernel) | |
int | computeNearestGeodesicNeighbour (int i, const Mat &distances_xi_x_sorted, real *dist_i=0) const |
Return the index j of the data point which satisfies: 1. | |
real | computeShortestDistance (int i, const Mat &distances_xi_x_sorted) const |
Return the shortest (geodesic) distance to i from a point x whose (non-geodesic) distance to its knn nearest neighbors in the training set is given by the matrix 'distances_xi_x_sorted', whose first column should contain the sorted distances, and whose second column should contain the corresponding indices. | |
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_i_x_again (int i, const Vec &x, real squared_norm_of_x=-1, bool first_time=false) const |
Return evaluate(data(i),x), where x is the same as in the precedent call to this same function (except if 'first_time' is true). | |
virtual real | evaluate_i_x_from_distances (int i, const Mat &distances_xi_x_sorted) const |
Evaluate K(x_i,x) where x is not given explicitly, but only by the (sorted and non-geodesic) distances to all training points. | |
virtual void | setDataForKernelMatrix (VMat the_data) |
Overridden to precompute inter-points geodesic distance. | |
Public Attributes | |
Ker | distance_kernel |
string | geodesic_file |
int | knn |
bool | pow_distance |
string | shortest_algo |
VMat | geo_distances |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Private Types | |
typedef Kernel | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
Private Attributes | |
Mat | dist_xi_x_sorted1 |
Used to store data and save memory allocation. | |
Mat | dist_xi_x_sorted2 |
Used to store data and save memory allocation. | |
Mat | dist_xi_x_sorted |
Used to store data and save memory allocation. |
|
Reimplemented from PLearn::Kernel. Definition at line 57 of file GeodesicDistanceKernel.h. |
|
Default constructor.
Definition at line 54 of file GeodesicDistanceKernel.cc. References distance_kernel. |
|
Convenient constructor.
Definition at line 63 of file GeodesicDistanceKernel.cc. References build(), and distance_kernel. |
|
Simply calls inherited::build() then build_().
Reimplemented from PLearn::Kernel. Definition at line 115 of file GeodesicDistanceKernel.cc. References build_(). Referenced by GeodesicDistanceKernel(). |
|
This does the actual building.
Reimplemented from PLearn::Kernel. Definition at line 124 of file GeodesicDistanceKernel.cc. Referenced by build(). |
|
Return the index j of the data point which satisfies: 1. j is among the knn nearest neighbors of the point x from which was computed 'distances_xi_x_sorted' 2. it is such that dist(x,j) + geodesic_dist(j,x_i) is minimum If provided, the 'dist_i' parameter is filled with the geodesic distance from x to x_i. Definition at line 131 of file GeodesicDistanceKernel.cc. References PLearn::dist(), geo_distances, knn, PLearn::Mat, and PLearn::min(). Referenced by computeShortestDistance(). |
|
Return the shortest (geodesic) distance to i from a point x whose (non-geodesic) distance to its knn nearest neighbors in the training set is given by the matrix 'distances_xi_x_sorted', whose first column should contain the sorted distances, and whose second column should contain the corresponding indices.
Definition at line 150 of file GeodesicDistanceKernel.cc. References computeNearestGeodesicNeighbour(). Referenced by evaluate_i_x_again(), and evaluate_i_x_from_distances(). |
|
Declares this class' options.
Reimplemented from PLearn::Kernel. Definition at line 82 of file GeodesicDistanceKernel.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
Compute K(x1,x2).
Implements PLearn::Kernel. Definition at line 159 of file GeodesicDistanceKernel.cc. References PLearn::dist(), dist_xi_x_sorted1, dist_xi_x_sorted2, distance_kernel, geo_distances, k, knn, PLearn::min(), pow_distance, REAL_MAX, PLearn::square(), and PLearn::Vec. |
|
returns evaluate(data(i),data(j))
Reimplemented from PLearn::Kernel. Definition at line 183 of file GeodesicDistanceKernel.cc. References geo_distances, pow_distance, and PLearn::square(). |
|
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 194 of file GeodesicDistanceKernel.cc. References evaluate_i_x_again(), and x. |
|
Return evaluate(data(i),x), where x is the same as in the precedent call to this same function (except if 'first_time' is true). This can be used to speed up successive computations of K(x_i, x) (default version just calls evaluate_i_x). Reimplemented from PLearn::Kernel. Definition at line 212 of file GeodesicDistanceKernel.cc. References computeShortestDistance(), dist_xi_x_sorted, distance_kernel, knn, pow_distance, PLearn::square(), and x. Referenced by evaluate_i_x(). |
|
Evaluate K(x_i,x) where x is not given explicitly, but only by the (sorted and non-geodesic) distances to all training points.
Definition at line 201 of file GeodesicDistanceKernel.cc. References computeShortestDistance(), pow_distance, and PLearn::square(). |
|
Transforms a shallow copy into a deep copy.
Definition at line 226 of file GeodesicDistanceKernel.cc. References PLERROR. |
|
|
|
Overridden to precompute inter-points geodesic distance.
Reimplemented from PLearn::Kernel. Definition at line 243 of file GeodesicDistanceKernel.cc. References PLearn::TVec< T >::append(), PLearn::dist(), distance_kernel, PLearn::TVec< T >::fill(), PLearn::TMat< T >::fill(), geo_distances, geodesic_file, k, knn, PLearn::TVec< T >::length(), PLearn::VMat::length(), PLearn::min(), PLERROR, REAL_MAX, shortest_algo, PLearn::ProgressBar::update(), and PLearn::VMat::width(). |
|
Used to store data and save memory allocation.
Definition at line 60 of file GeodesicDistanceKernel.h. Referenced by evaluate_i_x_again(). |
|
Used to store data and save memory allocation.
Definition at line 60 of file GeodesicDistanceKernel.h. Referenced by evaluate(). |
|
Used to store data and save memory allocation.
Definition at line 60 of file GeodesicDistanceKernel.h. Referenced by evaluate(). |
|
Definition at line 74 of file GeodesicDistanceKernel.h. Referenced by evaluate(), evaluate_i_x_again(), GeodesicDistanceKernel(), and setDataForKernelMatrix(). |
|
Definition at line 79 of file GeodesicDistanceKernel.h. Referenced by computeNearestGeodesicNeighbour(), evaluate(), evaluate_i_j(), and setDataForKernelMatrix(). |
|
Definition at line 75 of file GeodesicDistanceKernel.h. Referenced by setDataForKernelMatrix(). |
|
Definition at line 76 of file GeodesicDistanceKernel.h. Referenced by computeNearestGeodesicNeighbour(), evaluate(), evaluate_i_x_again(), and setDataForKernelMatrix(). |
|
Definition at line 77 of file GeodesicDistanceKernel.h. Referenced by evaluate(), evaluate_i_j(), evaluate_i_x_again(), and evaluate_i_x_from_distances(). |
|
Definition at line 78 of file GeodesicDistanceKernel.h. Referenced by setDataForKernelMatrix(). |