[mlpack-git] master: Comment out most of the debugging output. It still shows you what's been Hamerly pruned and what hasn't, which is what's important right now. (eba305d)

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


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

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

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

commit eba305d23f39d7ee57f5ee93c82d970b70f8f608
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Jan 27 17:31:01 2015 -0500

    Comment out most of the debugging output. It still shows you what's been Hamerly pruned and what hasn't, which is what's important right now.


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

eba305d23f39d7ee57f5ee93c82d970b70f8f608
 .../methods/kmeans/dual_tree_kmeans_impl.hpp       | 129 +++++++++++----------
 .../methods/kmeans/dual_tree_kmeans_rules_impl.hpp | 104 ++++++++---------
 2 files changed, 117 insertions(+), 116 deletions(-)

diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp
index 16680a8..22dd0ad 100644
--- a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp
@@ -187,15 +187,15 @@ void DualTreeKMeans<MetricType, MatType, TreeType>::TreeUpdate(
     node->Stat().Owner() = node->Parent()->Stat().Owner();
 
   const size_t cluster = assignments[node->Descendant(0)];
-  if (node->Begin() == 16954)
-    Log::Info << "r16954c" << node->Count() << ", descendant 0 has cluster "
-        << cluster << ".\n";
+//  if (node->Begin() == 16954)
+//    Log::Info << "r16954c" << node->Count() << ", descendant 0 has cluster "
+//        << cluster << ".\n";
   bool allSame = true;
   for (size_t i = 1; i < node->NumDescendants(); ++i)
   {
-    if (node->Begin() == 16954)
-      Log::Info << "Descendant " << i << " has cluster " <<
-          assignments[node->Descendant(i)] << ".\n";
+//    if (node->Begin() == 16954)
+//      Log::Info << "Descendant " << i << " has cluster " <<
+//          assignments[node->Descendant(i)] << ".\n";
     if (assignments[node->Descendant(i)] != cluster)
     {
       allSame = false;
@@ -231,10 +231,10 @@ void DualTreeKMeans<MetricType, MatType, TreeType>::TreeUpdate(
     if (node->Stat().SecondClosestBound() == DBL_MAX && node->Parent() == NULL)
       node->Stat().SecondClosestBound() = 0.0; // Don't prune the root.
 
-    if (node->Begin() == 16954)
-      Log::Warn << "r16954c" << node->Count() << " scb " <<
-node->Stat().SecondClosestBound() << " and lscb " <<
-node->Stat().LastSecondClosestBound() << ".\n";
+//    if (node->Begin() == 16954)
+//      Log::Warn << "r16954c" << node->Count() << " scb " <<
+//node->Stat().SecondClosestBound() << " and lscb " <<
+//node->Stat().LastSecondClosestBound() << ".\n";
 
     // If both the second closest bound and last second closest bound are valid,
     // we have the option of taking the better of the two bounds.  But if only
@@ -266,26 +266,26 @@ node->Stat().LastSecondClosestBound() << ".\n";
       // pruned by the parent, and was thus never visited with this node.  This
       // situation occurs if the second closest query node is not a descendant
       // of the second closest query node of the parent.
-      if (node->Stat().SecondClosestQueryNode() != NULL)
-      {
-        if (node->Begin() == 16954)
-        {
-          Log::Warn << "Second closest query node is q" << ((TreeType*)
-node->Stat().SecondClosestQueryNode())->Begin() << "c" << ((TreeType*)
-node->Stat().SecondClosestQueryNode())->Count() << ", with scb " <<
-node->Stat().SecondClosestBound() << ".\n";
-          Log::Warn << "True SCB to this node should be " <<
-node->MinDistance((TreeType*) node->Stat().SecondClosestQueryNode()) << ".\n";
-        }
-      }
-
-      if (node->Stat().ClosestQueryNode() != NULL)
-        if (node->Begin() == 16954)
-          Log::Warn << "Closest query node: q" << ((TreeType*)
-node->Stat().ClosestQueryNode())->Begin() << "c" << ((TreeType*)
-node->Stat().ClosestQueryNode())->Count() << ", with MQND " <<
-node->Stat().MaxQueryNodeDistance() << " and mQND " <<
-node->Stat().MinQueryNodeDistance() << ".\n";
+//      if (node->Stat().SecondClosestQueryNode() != NULL)
+//      {
+//        if (node->Begin() == 16954)
+//        {
+//          Log::Warn << "Second closest query node is q" << ((TreeType*)
+//node->Stat().SecondClosestQueryNode())->Begin() << "c" << ((TreeType*)
+//node->Stat().SecondClosestQueryNode())->Count() << ", with scb " <<
+//node->Stat().SecondClosestBound() << ".\n";
+//          Log::Warn << "True SCB to this node should be " <<
+//node->MinDistance((TreeType*) node->Stat().SecondClosestQueryNode()) << ".\n";
+//        }
+//      }
+
+//      if (node->Stat().ClosestQueryNode() != NULL)
+//        if (node->Begin() == 16954)
+//          Log::Warn << "Closest query node: q" << ((TreeType*)
+//node->Stat().ClosestQueryNode())->Begin() << "c" << ((TreeType*)
+//node->Stat().ClosestQueryNode())->Count() << ", with MQND " <<
+//node->Stat().MaxQueryNodeDistance() << " and mQND " <<
+//node->Stat().MinQueryNodeDistance() << ".\n";
 
       // If the closest query node contains more than one descendant, we have to
       // find the closest...
@@ -327,21 +327,21 @@ node->Stat().MinQueryNodeDistance() << ".\n";
         if (secondClosestDistance < node->Stat().SecondClosestBound())
           node->Stat().SecondClosestBound() = secondClosestDistance;
 
-      if (node->Begin() == 16954)
-        Log::Warn << "After recalculation, closest for r" << node->Begin() << "c" << node->Count()
-<< " is " << closest << ", with mQND " << node->Stat().MinQueryNodeDistance() <<
-", MQND" << node->Stat().MaxQueryNodeDistance() << ", and scb " <<
-node->Stat().SecondClosestBound() << ", " << secondClosest << ".\n";
+//      if (node->Begin() == 16954)
+//        Log::Warn << "After recalculation, closest for r" << node->Begin() << "c" << node->Count()
+//<< " is " << closest << ", with mQND " << node->Stat().MinQueryNodeDistance() <<
+//", MQND" << node->Stat().MaxQueryNodeDistance() << ", and scb " <<
+//node->Stat().SecondClosestBound() << ", " << secondClosest << ".\n";
       }
 
       if (node->Parent() != NULL &&
 node->Parent()->Stat().SecondClosestQueryNode() != NULL)
-        if (node->Begin() == 16954)
-          Log::Warn << "Parent's (r" << node->Parent()->Begin() << "c"
-<< node->Parent()->Count() << ") second closest query node is q" << ((TreeType*)
-node->Parent()->Stat().SecondClosestQueryNode())->Begin() << "c" << ((TreeType*)
-node->Parent()->Stat().SecondClosestQueryNode())->Count() << ", with scb " <<
-node->Parent()->Stat().SecondClosestBound() << ".\n";
+//        if (node->Begin() == 16954)
+//          Log::Warn << "Parent's (r" << node->Parent()->Begin() << "c"
+//<< node->Parent()->Count() << ") second closest query node is q" << ((TreeType*)
+//node->Parent()->Stat().SecondClosestQueryNode())->Begin() << "c" << ((TreeType*)
+//node->Parent()->Stat().SecondClosestQueryNode())->Count() << ", with scb " <<
+//node->Parent()->Stat().SecondClosestBound() << ".\n";
 
       if (node->Parent() != NULL && 
           node->Stat().SecondClosestQueryNode() != NULL &&
@@ -352,11 +352,11 @@ node->Stat().SecondClosestQueryNode())))
         // Does this even work?
         const double minDistance = node->MinDistance((TreeType*)
             node->Parent()->Stat().SecondClosestQueryNode());
-        if (node->Begin() == 16954)
-          Log::Warn << "r16954c" << node->Count() << " has min distance " <<
-minDistance << " to SCQN of parent (q" << ((TreeType*)
-node->Parent()->Stat().SecondClosestQueryNode())->Begin() << "c" << ((TreeType*)
-node->Parent()->Stat().SecondClosestQueryNode())->Count() << ")\n";
+//        if (node->Begin() == 16954)
+//          Log::Warn << "r16954c" << node->Count() << " has min distance " <<
+//minDistance << " to SCQN of parent (q" << ((TreeType*)
+//node->Parent()->Stat().SecondClosestQueryNode())->Begin() << "c" << ((TreeType*)
+//node->Parent()->Stat().SecondClosestQueryNode())->Count() << ")\n";
 
         if (minDistance < node->Stat().SecondClosestBound())
         {
@@ -364,17 +364,17 @@ node->Parent()->Stat().SecondClosestQueryNode())->Count() << ")\n";
               node->Parent()->Stat().SecondClosestBound();
           node->Stat().SecondClosestQueryNode() =
               node->Parent()->Stat().SecondClosestQueryNode();
-          if (node->Begin() == 16954)
-            Log::Warn << "r16954c" << node->Count() << " has recalculated scb "
-                << node->Stat().SecondClosestBound() << ".\n";
+//          if (node->Begin() == 16954)
+//            Log::Warn << "r16954c" << node->Count() << " has recalculated scb "
+//                << node->Stat().SecondClosestBound() << ".\n";
         }
       }
     }
 
-    if (node->Begin() == 16954)
-      Log::Warn << "r16954c" << node->Count() << " now scb " <<
-node->Stat().SecondClosestBound() << " and lscb " <<
-node->Stat().LastSecondClosestBound() << ".\n";
+//    if (node->Begin() == 16954)
+//      Log::Warn << "r16954c" << node->Count() << " now scb " <<
+//node->Stat().SecondClosestBound() << " and lscb " <<
+//node->Stat().LastSecondClosestBound() << ".\n";
 //      if (node->Begin() == 16954)
 //        Log::Warn << "Update second closest bound for r16954c" <<
 //node->Count() << " to " << node->Stat().SecondClosestBound() << ", which could "
@@ -407,14 +407,14 @@ node->Parent()->Stat().SecondClosestBound() < node->Stat().SecondClosestBound())
 node->Parent()->Stat().SecondClosestBound();
     }*/
 
-    if (node->Begin() == 16954)
-    {
-      Log::Warn << "Attempt Hamerly prune on r16954c" << node->Count() <<
-          " with MQND " << node->Stat().MaxQueryNodeDistance() << ", scb "
-          << node->Stat().SecondClosestBound() << ", owner " <<
-node->Stat().Owner() << ", and clusterDistances " << clusterDistances[clusters]
-<< ".\n";
-    }
+//    if (node->Begin() == 16954)
+//    {
+//      Log::Warn << "Attempt Hamerly prune on r16954c" << node->Count() <<
+//          " with MQND " << node->Stat().MaxQueryNodeDistance() << ", scb "
+//          << node->Stat().SecondClosestBound() << ", owner " <<
+//node->Stat().Owner() << ", and clusterDistances " << clusterDistances[clusters]
+//<< ".\n";
+//    }
 
     // Check the second bound.  (This is time-consuming...)
     for (size_t j = 0; j < node->NumDescendants(); ++j)
@@ -431,8 +431,8 @@ node->Stat().Owner() << ", and clusterDistances " << clusterDistances[clusters]
         distances(i) = distance;
       }
 
-        if (node->Begin() == 16954)
-          Log::Warn << "r16954c" << node->Count() << ": " << distances.t();
+//        if (node->Begin() == 16954)
+//          Log::Warn << "r16954c" << node->Count() << ": " << distances.t();
       if (secondClosestDist < node->Stat().SecondClosestBound() - 1e-15)
       {
         Log::Warn << "r" << node->Begin() << "c" << node->Count() << ":\n";
@@ -451,7 +451,8 @@ node->Stat().SecondClosestBound() << " is too loose! -- " << secondClosestDist
         - clusterDistances[clusters])
     {
       node->Stat().HamerlyPruned() = true;
-      if (node->Begin() == 16954)
+//      if (node->Begin() == 16954)
+      if (!node->Parent()->Stat().HamerlyPruned())
         Log::Warn << "Mark r" << node->Begin() << "c" << node->Count() << " as "
             << "Hamerly pruned.\n";
     }
diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp
index d8e9069..1ab28f4 100644
--- a/src/mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp
+++ b/src/mlpack/methods/kmeans/dual_tree_kmeans_rules_impl.hpp
@@ -113,9 +113,9 @@ double DualTreeKMeansRules<MetricType, TreeType>::Score(
 
   traversalInfo.LastReferenceNode() = &referenceNode;
 
-  if (referenceNode.Begin() == 16954)
-    Log::Warn << "Visit r16954c" << referenceNode.Count() << ", q" <<
-queryNode.Begin() << "c" << queryNode.Count() << ".\n";
+//  if (referenceNode.Begin() == 16954)
+//    Log::Warn << "Visit r16954c" << referenceNode.Count() << ", q" <<
+//queryNode.Begin() << "c" << queryNode.Count() << ".\n";
 
   // If there's no closest query node assigned, but the parent has one, take
   // that one.
@@ -123,13 +123,13 @@ queryNode.Begin() << "c" << queryNode.Count() << ".\n";
       referenceNode.Parent() != NULL &&
       referenceNode.Parent()->Stat().ClosestQueryNode() != NULL)
   {
-    if (referenceNode.Begin() == 16954)
-      Log::Warn << "Update closest query node for r16954c" <<
-referenceNode.Count() << " to parent's, which is "
-          << ((TreeType*)
-referenceNode.Parent()->Stat().ClosestQueryNode())->Begin() << "c" <<
-((TreeType*) referenceNode.Parent()->Stat().ClosestQueryNode())->Count() <<
-".\n";
+//    if (referenceNode.Begin() == 16954)
+//      Log::Warn << "Update closest query node for r16954c" <<
+//referenceNode.Count() << " to parent's, which is "
+//          << ((TreeType*)
+//referenceNode.Parent()->Stat().ClosestQueryNode())->Begin() << "c" <<
+//((TreeType*) referenceNode.Parent()->Stat().ClosestQueryNode())->Count() <<
+//".\n";
 
     referenceNode.Stat().ClosestQueryNode() =
         referenceNode.Parent()->Stat().ClosestQueryNode();
@@ -148,9 +148,9 @@ referenceNode.Parent()->Stat().ClosestQueryNode())->Begin() << "c" <<
   double score = HamerlyTypeScore(referenceNode);
   if (score == DBL_MAX)
   {
-    if (referenceNode.Begin() == 16954)
-      Log::Warn << "Hamerly prune for r16954c" << referenceNode.Count() << ", q" << queryNode.Begin() << "c" <<
-queryNode.Count() << ".\n";
+//    if (referenceNode.Begin() == 16954)
+//      Log::Warn << "Hamerly prune for r16954c" << referenceNode.Count() << ", q" << queryNode.Begin() << "c" <<
+//queryNode.Count() << ".\n";
     if (origPruned == size_t(-1))
     {
       const size_t cluster = referenceNode.Stat().Owner();
@@ -175,11 +175,11 @@ queryNode.Count() << ".\n";
       const double minDistance = referenceNode.MinDistance(&queryNode);
       ++distanceCalculations;
       score = PellegMooreScore(queryNode, referenceNode, minDistance);
-      if (referenceNode.Begin() == 16954)
-        Log::Warn << "mQND for r16954c" << referenceNode.Count() << " is "
-            << referenceNode.Stat().MinQueryNodeDistance() << "; minDistance "
-            << minDistance << ", scb " <<
-referenceNode.Stat().SecondClosestBound() << ".\n";
+//      if (referenceNode.Begin() == 16954)
+//        Log::Warn << "mQND for r16954c" << referenceNode.Count() << " is "
+//            << referenceNode.Stat().MinQueryNodeDistance() << "; minDistance "
+//            << minDistance << ", scb " <<
+//referenceNode.Stat().SecondClosestBound() << ".\n";
 
       if (minDistance < referenceNode.Stat().MinQueryNodeDistance())
       {
@@ -194,10 +194,10 @@ referenceNode.Stat().SecondClosestBound() << ".\n";
               referenceNode.Stat().MinQueryNodeDistance();
           referenceNode.Stat().SecondClosestQueryNode() =
               referenceNode.Stat().ClosestQueryNode();
-          if (referenceNode.Begin() == 16954)
-            Log::Warn << "scb for r16954c" << referenceNode.Count() << " taken "
-                << "from minDistance, which is " <<
-referenceNode.Stat().MinQueryNodeDistance() << ".\n";
+//          if (referenceNode.Begin() == 16954)
+//            Log::Warn << "scb for r16954c" << referenceNode.Count() << " taken "
+//                << "from minDistance, which is " <<
+//referenceNode.Stat().MinQueryNodeDistance() << ".\n";
         }
 
         if (referenceNode.Stat().MinQueryNodeDistance() == DBL_MAX &&
@@ -206,10 +206,10 @@ referenceNode.Stat().MinQueryNodeDistance() << ".\n";
         {
           referenceNode.Stat().SecondClosestBound() = minDistance;
           referenceNode.Stat().SecondClosestQueryNode() = &queryNode;
-          if (referenceNode.Begin() == 16954)
-            Log::Warn << "scb for r16954c" << referenceNode.Count() << " taken "
-                << "from minDistance for pruned query node, which is " <<
-minDistance << ".\n";
+//          if (referenceNode.Begin() == 16954)
+//            Log::Warn << "scb for r16954c" << referenceNode.Count() << " taken "
+//                << "from minDistance for pruned query node, which is " <<
+//minDistance << ".\n";
         }
 
         if (score != DBL_MAX)
@@ -219,40 +219,40 @@ minDistance << ".\n";
           referenceNode.Stat().MinQueryNodeDistance() = minDistance;
           referenceNode.Stat().MaxQueryNodeDistance() = maxDistance;
 
-          if (referenceNode.Begin() == 16954)
-            Log::Warn << "mQND for r16954c" << referenceNode.Count() << " updated to " << minDistance << " and "
-              << "MQND to " << maxDistance << " with furthest query node " <<
-              queryNode.Begin() << "c" << queryNode.Count() << ".\n";
+//          if (referenceNode.Begin() == 16954)
+//            Log::Warn << "mQND for r16954c" << referenceNode.Count() << " updated to " << minDistance << " and "
+//              << "MQND to " << maxDistance << " with furthest query node " <<
+//              queryNode.Begin() << "c" << queryNode.Count() << ".\n";
         }
       }
       else if (IsDescendantOf(*((TreeType*)
           referenceNode.Stat().ClosestQueryNode()), queryNode))
       {
-        if (referenceNode.Begin() == 16954)
-          Log::Warn << "Old closest for r16954c" << referenceNode.Count() <<
-              " is q" << ((TreeType*)
-referenceNode.Stat().ClosestQueryNode())->Begin() << "c" << ((TreeType*)
-referenceNode.Stat().ClosestQueryNode())->Count() << " with mQND " <<
-referenceNode.Stat().MinQueryNodeDistance() << " and MQND " <<
-referenceNode.Stat().MaxQueryNodeDistance() << ".\n";
+//        if (referenceNode.Begin() == 16954)
+//          Log::Warn << "Old closest for r16954c" << referenceNode.Count() <<
+//              " is q" << ((TreeType*)
+//referenceNode.Stat().ClosestQueryNode())->Begin() << "c" << ((TreeType*)
+//referenceNode.Stat().ClosestQueryNode())->Count() << " with mQND " <<
+//referenceNode.Stat().MinQueryNodeDistance() << " and MQND " <<
+//referenceNode.Stat().MaxQueryNodeDistance() << ".\n";
         const double maxDistance = referenceNode.MaxDistance(&queryNode);
         ++distanceCalculations;
         referenceNode.Stat().ClosestQueryNode() = (void*) &queryNode;
         referenceNode.Stat().MinQueryNodeDistance() = minDistance;
         referenceNode.Stat().MaxQueryNodeDistance() = maxDistance;
 
-        if (referenceNode.Begin() == 16954)
-          Log::Warn << "mQND for r16954c" << referenceNode.Count() << " updated to " << minDistance << " and "
-              << "MQND to " << maxDistance << " via descendant with fqn " <<
-              queryNode.Begin() << "c" << queryNode.Count() << ".\n";
+//        if (referenceNode.Begin() == 16954)
+//          Log::Warn << "mQND for r16954c" << referenceNode.Count() << " updated to " << minDistance << " and "
+//              << "MQND to " << maxDistance << " via descendant with fqn " <<
+//              queryNode.Begin() << "c" << queryNode.Count() << ".\n";
       }
       else if (minDistance < referenceNode.Stat().SecondClosestBound())
       {
         referenceNode.Stat().SecondClosestBound() = minDistance;
         referenceNode.Stat().SecondClosestQueryNode() = &queryNode;
-        if (referenceNode.Begin() == 16954)
-          Log::Warn << "scb for r16954c" << referenceNode.Count() << " updated to " << minDistance << " via "
-              << queryNode.Begin() << "c" << queryNode.Count() << ".\n";
+//        if (referenceNode.Begin() == 16954)
+//          Log::Warn << "scb for r16954c" << referenceNode.Count() << " updated to " << minDistance << " via "
+//              << queryNode.Begin() << "c" << queryNode.Count() << ".\n";
       }
     }
   }
@@ -268,11 +268,11 @@ referenceNode.Stat().MaxQueryNodeDistance() << ".\n";
   if (score == DBL_MAX)
   {
     referenceNode.Stat().ClustersPruned() += queryNode.NumDescendants();
-    if (referenceNode.Begin() == 16954)
-      Log::Warn << "For r16954c" << referenceNode.Count() << ", q" <<
-queryNode.Begin() << "c" << queryNode.Count() << " is pruned.  Min distance is"
-    << " " << queryNode.MinDistance(&referenceNode) << " and scb is " <<
-referenceNode.Stat().SecondClosestBound() << ".\n";
+//    if (referenceNode.Begin() == 16954)
+//      Log::Warn << "For r16954c" << referenceNode.Count() << ", q" <<
+//queryNode.Begin() << "c" << queryNode.Count() << " is pruned.  Min distance is"
+//    << " " << queryNode.MinDistance(&referenceNode) << " and scb is " <<
+//referenceNode.Stat().SecondClosestBound() << ".\n";
 
     // Have we pruned everything?
     if (referenceNode.Stat().ClustersPruned() +
@@ -327,9 +327,9 @@ double DualTreeKMeansRules<MetricType, TreeType>::HamerlyTypeScore(
 {
   if (referenceNode.Stat().HamerlyPruned())
   {
-    if (referenceNode.Begin() == 16954)
-      Log::Info << "Hamerly prune! r" << referenceNode.Begin() << "c" <<
-referenceNode.Count() << ".\n";
+//    if (referenceNode.Begin() == 16954)
+//      Log::Warn << "Hamerly prune! r" << referenceNode.Begin() << "c" <<
+//referenceNode.Count() << ".\n";
     return DBL_MAX;
   }
 



More information about the mlpack-git mailing list