[mlpack-git] master: Fix a bug where we pruned too tightly. Provide a little more debugging output for errors, too (but this debugging is commented out by default). (5ee125c)

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


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

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

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

commit 5ee125c678c8f14c7ea3849a66e97714b9d9f6c4
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Feb 27 13:46:57 2015 -0500

    Fix a bug where we pruned too tightly. Provide a little more debugging output for errors, too (but this debugging is commented out by default).


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

5ee125c678c8f14c7ea3849a66e97714b9d9f6c4
 src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp | 10 ++++++++--
 src/mlpack/methods/kmeans/dtnn_rules_impl.hpp  |  0
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
index fd771cc..f5eaf12 100644
--- a/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/dtnn_kmeans_impl.hpp
@@ -304,6 +304,8 @@ visited[node.Descendant(i)] << ".\n";
       const size_t index = node.Point(i);
       if (!visited[index] && !prunedPoints[index])
       {
+        upperBounds[index] = DBL_MAX; // Reset the bounds.
+        lowerBounds[index] = DBL_MAX;
         allPointsPruned = false;
         continue; // We didn't visit it and we don't have valid bounds -- so we
                   // can't prune it.
@@ -396,8 +398,10 @@ visited[node.Descendant(i)] << ".\n";
     }
     else
     {
-      node.Stat().StaticUpperBoundMovement() = 0.0;
-      node.Stat().StaticLowerBoundMovement() = 0.0;
+      node.Stat().StaticUpperBoundMovement() =
+          clusterDistances[node.Stat().Owner()];
+      node.Stat().StaticLowerBoundMovement() =
+          clusterDistances[centroids.n_cols];
     }
   }
 }
@@ -434,6 +438,7 @@ void DTNNKMeans<MetricType, MatType, TreeType>::ExtractCentroids(
       const double minDist = trueDistances.min(minIndex);
       if (size_t(minIndex) != owner)
       {
+        Log::Warn << node;
         Log::Warn << trueDistances.t();
         Log::Fatal << "Point " << index << " of node " << node.Point(0) << "c"
 << node.NumDescendants() << " has true minimum cluster " << minIndex << " with "
@@ -469,6 +474,7 @@ node.Stat().UpperBound() << " and owner " << node.Stat().Owner() << ".\n";
         const double minDist = trueDistances.min(minIndex);
         if (size_t(minIndex) != owner)
         {
+          Log::Warn << node;
           Log::Warn << trueDistances.t();
           Log::Fatal << "Point " << index << " of node " << node.Point(0) << "c"
   << node.NumDescendants() << " has true minimum cluster " << minIndex << " with "



More information about the mlpack-git mailing list