Some performance tuning
This commit is contained in:
@@ -429,6 +429,12 @@ class DenseLpr {
|
||||
|
||||
////////// Private Member Variables //////////
|
||||
|
||||
/** @brief The number of finite difference prunes. */
|
||||
int num_finite_difference_prunes_;
|
||||
|
||||
/** @brief The number of far-field prunes. */
|
||||
int num_far_field_prunes_;
|
||||
|
||||
/** @brief The local polynomial order. */
|
||||
int lpr_order_;
|
||||
|
||||
@@ -757,11 +763,18 @@ class DenseLpr {
|
||||
Vector *query_magnitude_weight_diagrams,
|
||||
Vector *query_influence_values) {
|
||||
|
||||
// Clear prune statistics.
|
||||
num_finite_difference_prunes_ = num_far_field_prunes_ = 0;
|
||||
|
||||
// This is the basic N-body based computation.
|
||||
BasicCompute_(queries, query_regression_estimates,
|
||||
query_confidence_bands, query_magnitude_weight_diagrams,
|
||||
query_influence_values);
|
||||
|
||||
printf("Number of finite difference prunes: %d\n",
|
||||
num_finite_difference_prunes_);
|
||||
printf("Number of far-field prunes: %d\n", num_far_field_prunes_);
|
||||
|
||||
// If the reference dataset is being used for training, then
|
||||
// compute variance and degrees of freedom.
|
||||
if(query_influence_values != NULL) {
|
||||
|
||||
@@ -473,6 +473,9 @@ void DenseLpr<TKernel, TPruneRule>::DualtreeLprCanonical_
|
||||
&(qnode->stat().postponed_weight_diagram_numerator_e_));
|
||||
qnode->stat().postponed_weight_diagram_numerator_used_error_ +=
|
||||
delta_weight_diagram_numerator_used_error;
|
||||
|
||||
// Keep track of the number of finite difference prunes.
|
||||
num_finite_difference_prunes_++;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -480,7 +483,8 @@ void DenseLpr<TKernel, TPruneRule>::DualtreeLprCanonical_
|
||||
// moments if the maximum distance between the two nodes is within
|
||||
// the bandwidth! This if-statement does not apply to the Gaussian
|
||||
// kernel, so I need to fix in the future!
|
||||
if(kernel_aux_.kernel_.bandwidth_sq() >= dsqd_range.hi) {
|
||||
if(kernel_aux_.kernel_.bandwidth_sq() >= dsqd_range.hi &&
|
||||
rnode->count() > 32) {
|
||||
|
||||
for(index_t q = qnode->begin(); q < qnode->end(); q++) {
|
||||
for(index_t j = 0; j < row_length_; j++) {
|
||||
@@ -512,6 +516,9 @@ void DenseLpr<TKernel, TPruneRule>::DualtreeLprCanonical_
|
||||
|
||||
la::AddTo(weight_diagram_numerator_dl,
|
||||
&(qnode->stat().postponed_weight_diagram_numerator_l_));
|
||||
|
||||
// Keep track of the far-field prunes.
|
||||
num_far_field_prunes_++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,18 +55,22 @@ int main(int argc, char *argv[]) {
|
||||
DatasetScaler::ScaleDataByMinMax(queries, references, false);
|
||||
|
||||
// Do fast algorithm.
|
||||
printf("Running the fast algorithm...\n");
|
||||
Vector fast_lpr_results;
|
||||
DenseLpr<EpanKernelAux, RelativePruneLpr> fast_lpr;
|
||||
fast_lpr.Init(references, reference_targets, local_linear_module);
|
||||
fast_lpr.PrintDebug();
|
||||
fast_lpr.get_regression_estimates(&fast_lpr_results);
|
||||
printf("Finished running the fast algorithm...\n");
|
||||
|
||||
// Do naive algorithm.
|
||||
printf("Running the naive algorithm...\n");
|
||||
Vector naive_lpr_results;
|
||||
NaiveLpr<EpanKernel> naive_lpr;
|
||||
naive_lpr.Init(references, reference_targets, local_linear_module);
|
||||
naive_lpr.PrintDebug();
|
||||
naive_lpr.get_regression_estimates(&naive_lpr_results);
|
||||
printf("Finished running the naive algorithm...\n");
|
||||
|
||||
printf("Maximum relative difference: %g\n",
|
||||
MatrixUtil::MaxRelativeDifference(naive_lpr_results,
|
||||
|
||||
@@ -122,12 +122,12 @@ class RelativePruneLpr {
|
||||
denominator_used_error = kernel_error *
|
||||
(rnode->stat().sum_data_outer_products_error_norm_);
|
||||
denominator_n_pruned = rnode->stat().sum_data_outer_products_alloc_norm_;
|
||||
|
||||
|
||||
// The total norm error for each query point for approximating
|
||||
// the B^T W(q)^2 B matrix.
|
||||
weight_diagram_numerator_used_error = squared_kernel_error *
|
||||
(rnode->stat().sum_data_outer_products_error_norm_);
|
||||
|
||||
|
||||
// Check pruning condition.
|
||||
return (numerator_used_error <= numerator_allowed_err &&
|
||||
denominator_used_error <= denominator_allowed_err &&
|
||||
|
||||
Reference in New Issue
Block a user