[mlpack-git] master: Run NNS on the centroids. No prune yet. (2453a81)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 12 16:04:15 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/eddd7167d69b6c88b271ef2e51d1c20e13f1acd8...70342dd8e5c17e0c164cfb8189748671e9c0dd44

>---------------------------------------------------------------

commit 2453a81ca0853aeb3df80fa6ed25ce22f999e388
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sun Feb 1 21:16:17 2015 -0500

    Run NNS on the centroids. No prune yet.


>---------------------------------------------------------------

2453a81ca0853aeb3df80fa6ed25ce22f999e388
 src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
index a537fb2..f71d791 100644
--- a/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
@@ -95,6 +95,14 @@ double DTNNKMeans<MetricType, MatType, TreeType>::Iterate(
   TreeType* centroidTree = BuildTree<TreeType>(
       const_cast<typename TreeType::Mat&>(centroids), oldFromNewCentroids);
 
+  // Find the nearest neighbors of each of the clusters.
+  neighbor::NeighborSearch<neighbor::NearestNeighborSort, MetricType, TreeType>
+      nns(centroidTree, centroids);
+  arma::mat interclusterDistances;
+  arma::Mat<size_t> closestClusters; // We don't actually care about these.
+  nns.Search(1, closestClusters, interclusterDistances);
+  distanceCalculations += nns.BaseCases() + nns.Scores();
+
   // We won't use the AllkNN class here because we have our own set of rules.
   // This is a lot of overhead.  We don't need the distances.
   arma::mat distances(2, dataset.n_cols);



More information about the mlpack-git mailing list