[mlpack-git] master: Always mark the owner. This fixes some unusual and unexpected floating point errors where the owner will not actually be set. (3f76388)

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


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

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

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

commit 3f763886f33e8a664fcff293c2cfe0702fbac707
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Feb 27 19:20:39 2015 -0500

    Always mark the owner. This fixes some unusual and unexpected floating point errors where the owner will not actually be set.


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

3f763886f33e8a664fcff293c2cfe0702fbac707
 src/mlpack/methods/kmeans/dtnn_rules_impl.hpp | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/mlpack/methods/kmeans/dtnn_rules_impl.hpp b/src/mlpack/methods/kmeans/dtnn_rules_impl.hpp
index 2a68754..d7890aa 100644
--- a/src/mlpack/methods/kmeans/dtnn_rules_impl.hpp
+++ b/src/mlpack/methods/kmeans/dtnn_rules_impl.hpp
@@ -205,10 +205,8 @@ inline double DTNNKMeansRules<MetricType, TreeType>::Score(
   }
 
   // Now, check if we can prune.
-  //Log::Warn << "adjusted score: " << adjustedScore << ".\n";
   if (adjustedScore > queryNode.Stat().UpperBound())
   {
-//    Log::Warn << "Pre-emptive prune!\n";
     if (!(tree::TreeTraits<TreeType>::FirstPointIsCentroid && score == 0.0))
     {
       // There isn't any need to set the traversal information because no
@@ -257,12 +255,15 @@ inline double DTNNKMeansRules<MetricType, TreeType>::Score(
       {
         // We can improve the best estimate.
         queryNode.Stat().UpperBound() = tighterBound;
-        // If this node has only one descendant, then it may be the owner.
-        if (referenceNode.NumDescendants() == 1)
-          queryNode.Stat().Owner() =
-              (tree::TreeTraits<TreeType>::RearrangesDataset) ?
-              oldFromNewCentroids[referenceNode.Descendant(0)] :
-              referenceNode.Descendant(0);
+
+        // Remember that our upper bound does correspond to a cluster centroid,
+        // so it does correspond to a cluster.  We'll mark the cluster as the
+        // owner, but note that the node is not truly owned unless
+        // Stat().Pruned() is centroids.n_cols.
+        queryNode.Stat().Owner() =
+            (tree::TreeTraits<TreeType>::RearrangesDataset) ?
+            oldFromNewCentroids[referenceNode.Descendant(0)] :
+            referenceNode.Descendant(0);
       }
     }
   }



More information about the mlpack-git mailing list