[mlpack-git] master: Use tighter bounds for distances. More speedup. Only increase the distances by the maximum amount those particular clusters could have moved. (27c0096)

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


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

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

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

commit 27c0096984f110e82d22dc54d71a9e85615f1ec6
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Feb 3 17:26:10 2015 -0500

    Use tighter bounds for distances. More speedup. Only increase the distances by the maximum amount those particular clusters could have moved.


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

27c0096984f110e82d22dc54d71a9e85615f1ec6
 src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
index ae2dde7..3853837 100644
--- a/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
@@ -629,8 +629,9 @@ prunedPoints[index] << ", lastOwner " << lastOwners[index] << ": invalid "
   // Make sure all the point bounds are updated.
   for (size_t i = 0; i < node.NumPoints(); ++i)
   {
-    distances(0, node.Point(i)) += clusterDistances[centroids.n_cols];
-    distances(1, node.Point(i)) += clusterDistances[centroids.n_cols];
+    const size_t index = node.Point(i);
+    distances(0, index) += clusterDistances[assignments(0, index)];
+    distances(1, index) += clusterDistances[assignments(1, index)];
   }
 
   if (node.Stat().FirstBound() != DBL_MAX)



More information about the mlpack-git mailing list