From a6421c4dda1a83ea975bae545df1de16d38726b0 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 17 Feb 2017 15:38:08 -0800 Subject: [PATCH] Swap NaN count from index 7 to 2 within DebugNumericSummary ops. Change: 147888410 --- tensorflow/core/kernels/debug_ops.h | 12 ++++++------ tensorflow/core/kernels/debug_ops_test.cc | 18 +++++++++--------- .../python/debug/lib/session_debug_testlib.py | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tensorflow/core/kernels/debug_ops.h b/tensorflow/core/kernels/debug_ops.h index c6395f88722..df57cce45cc 100644 --- a/tensorflow/core/kernels/debug_ops.h +++ b/tensorflow/core/kernels/debug_ops.h @@ -241,12 +241,12 @@ class DebugNumericSummaryOp : public OpKernel { OP_REQUIRES_OK(context, context->allocate_output(0, shape, &output_tensor)); output_tensor->vec()(0) = static_cast(is_initialized); output_tensor->vec()(1) = static_cast(element_count); - output_tensor->vec()(2) = static_cast(negative_inf_count); - output_tensor->vec()(3) = static_cast(negative_count); - output_tensor->vec()(4) = static_cast(zero_count); - output_tensor->vec()(5) = static_cast(positive_count); - output_tensor->vec()(6) = static_cast(positive_inf_count); - output_tensor->vec()(7) = static_cast(nan_count); + output_tensor->vec()(2) = static_cast(nan_count); + output_tensor->vec()(3) = static_cast(negative_inf_count); + output_tensor->vec()(4) = static_cast(negative_count); + output_tensor->vec()(5) = static_cast(zero_count); + output_tensor->vec()(6) = static_cast(positive_count); + output_tensor->vec()(7) = static_cast(positive_inf_count); output_tensor->vec()(8) = min; output_tensor->vec()(9) = max; output_tensor->vec()(10) = mean; diff --git a/tensorflow/core/kernels/debug_ops_test.cc b/tensorflow/core/kernels/debug_ops_test.cc index ecddf2141d7..8442784cfdd 100644 --- a/tensorflow/core/kernels/debug_ops_test.cc +++ b/tensorflow/core/kernels/debug_ops_test.cc @@ -254,12 +254,12 @@ TEST_F(DebugNumericSummaryOpTest, Float_full_house) { &expected, {1.0, // Is initialized. 18.0, // Total element count. + 4.0, // nan count. 2.0, // -inf count. 2.0, // negative number count (excluding -inf). 3.0, // zero count. 2.0, // positive number count (excluding +inf). 5.0, // +inf count. - 4.0, // nan count. -3.0, // minimum of non-inf and non-nan elements. 7.0, // maximum of non-inf and non-nan elements. 0.85714285714, // mean of non-inf and non-nan elements. @@ -290,12 +290,12 @@ TEST_F(DebugNumericSummaryOpTest, Double_full_house) { &expected, {1.0, // Is initialized. 18.0, // Total element count. + 4.0, // nan count. 2.0, // -inf count. 2.0, // negative count (excluding -inf). 3.0, // zero count. 2.0, // positive count (excluding +inf). 5.0, // +inf count. - 4.0, // nan count. -3.0, // minimum of non-inf and non-nan elements. 7.0, // maximum of non-inf and non-nan elements. 0.85714285714, // mean of non-inf and non-nan elements. @@ -315,12 +315,12 @@ TEST_F(DebugNumericSummaryOpTest, Float_only_valid_values) { &expected, {1.0, // Is initialized. 6.0, // Total element count. + 0.0, // nan count. 0.0, // -inf count. 1.0, // negative count (excluding -inf). 2.0, // zero count. 3.0, // positive count (excluding +inf). 0.0, // +inf count. - 0.0, // nan count. -1.0, // minimum of non-inf and non-nan elements. 7.0, // maximum of non-inf and non-nan elements. 2.0, // mean of non-inf and non-nan elements. @@ -351,12 +351,12 @@ TEST_F(DebugNumericSummaryOpTest, Float_all_Inf_or_NaN) { // NaNs. ASSERT_NEAR(1.0, output[0], 1e-8); // Is initialized. ASSERT_NEAR(9.0, output[1], 1e-8); // Total element count. - ASSERT_NEAR(2.0, output[2], 1e-8); // -inf count. - ASSERT_NEAR(0.0, output[3], 1e-8); // negative count (excluding -inf). - ASSERT_NEAR(0.0, output[4], 1e-8); // zero count. - ASSERT_NEAR(0.0, output[5], 1e-8); // positive count (excluding +inf). - ASSERT_NEAR(3.0, output[6], 1e-8); // +inf count. - ASSERT_NEAR(4.0, output[7], 1e-8); // nan count. + ASSERT_NEAR(4.0, output[2], 1e-8); // nan count. + ASSERT_NEAR(2.0, output[3], 1e-8); // -inf count. + ASSERT_NEAR(0.0, output[4], 1e-8); // negative count (excluding -inf). + ASSERT_NEAR(0.0, output[5], 1e-8); // zero count. + ASSERT_NEAR(0.0, output[6], 1e-8); // positive count (excluding +inf). + ASSERT_NEAR(3.0, output[7], 1e-8); // +inf count. // Due to the absence of any non-inf and non-nan values, the output of min, // max, mean and var are all degenerate. ASSERT_EQ(std::numeric_limits::infinity(), output[8]); diff --git a/tensorflow/python/debug/lib/session_debug_testlib.py b/tensorflow/python/debug/lib/session_debug_testlib.py index 2042a3bea07..c6b229f786b 100644 --- a/tensorflow/python/debug/lib/session_debug_testlib.py +++ b/tensorflow/python/debug/lib/session_debug_testlib.py @@ -1060,7 +1060,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase): self.assertTrue(dump.loaded_partition_graphs()) self.assertAllClose([[ - 1.0, 18.0, 2.0, 2.0, 3.0, 2.0, 5.0, 4.0, -3.0, 7.0, 0.85714286, + 1.0, 18.0, 4.0, 2.0, 2.0, 3.0, 2.0, 5.0, -3.0, 7.0, 0.85714286, 8.97959184 ]], dump.get_tensors("numeric_summary/a/read", 0, "DebugNumericSummary"))