[mlpack-git] master: Update children before pruning points. This is an improvement for the cover tree. (803224f)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu May 28 15:31:53 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/5249c0fc83ac3b0915bd22ae1f1823b742a82c33...803224f64f6b6490c3cb8aafd528b1db069ef2f1
>---------------------------------------------------------------
commit 803224f64f6b6490c3cb8aafd528b1db069ef2f1
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu May 28 15:31:00 2015 -0400
Update children before pruning points.
This is an improvement for the cover tree.
>---------------------------------------------------------------
803224f64f6b6490c3cb8aafd528b1db069ef2f1
.../methods/kmeans/dual_tree_kmeans_impl.hpp | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp
index 135dece..70a5bdf 100644
--- a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp
@@ -332,6 +332,17 @@ visited[node.Descendant(i)] << ".\n";
node.Stat().LowerBound() -= clusterDistances[centroids.n_cols];
}
+ // Recurse into children, and if all the children (and all the points) are
+ // pruned, then we can mark this as statically pruned.
+ bool allChildrenPruned = true;
+ for (size_t i = 0; i < node.NumChildren(); ++i)
+ {
+ UpdateTree(node.Child(i), centroids, unadjustedUpperBound,
+ adjustedUpperBound, unadjustedLowerBound, adjustedLowerBound);
+ if (!node.Child(i).Stat().StaticPruned())
+ allChildrenPruned = false;
+ }
+
bool allPointsPruned = true;
if (tree::TreeTraits<TreeType>::HasSelfChildren && node.NumChildren() > 0)
{
@@ -407,17 +418,6 @@ visited[node.Descendant(i)] << ".\n";
}
}
- // Recurse into children, and if all the children (and all the points) are
- // pruned, then we can mark this as statically pruned.
- bool allChildrenPruned = true;
- for (size_t i = 0; i < node.NumChildren(); ++i)
- {
- UpdateTree(node.Child(i), centroids, unadjustedUpperBound,
- adjustedUpperBound, unadjustedLowerBound, adjustedLowerBound);
- if (!node.Child(i).Stat().StaticPruned())
- allChildrenPruned = false;
- }
-
/*
if (node.Stat().StaticPruned() && !allChildrenPruned)
{
More information about the mlpack-git
mailing list