Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix print function with tf_logging.info to keep consistence #18423

Merged
merged 6 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ def _VerifyValues(self, tensor_in_sizes, filter_in_sizes, bias, strides,
conv = tensors[i]
value = values[i]
ref_value = ref_values[i]
print("expected = ", ref_value)
print("actual = ", value)
tf_logging.info("expected = ", ref_value)
tf_logging.info("actual = ", value)
tol = 1e-5
if value.dtype == np.float16:
tol = 1e-3
Expand Down Expand Up @@ -831,7 +831,8 @@ def runTest(self, test_param):
vertical_stride, padding_type)
output_width = CalculateConvolvedOutputDim(input_width, filter_width,
horizontal_stride, padding_type)
print("output_height=", output_height, ", output_width=", output_width)
tf_logging.info("output_height=", output_height, ", output_width=",
output_width)

side_input, _, _ = gen_array_ops.quantize_v2(
random_ops.random_uniform(
Expand Down Expand Up @@ -866,8 +867,8 @@ def runTest(self, test_param):

with self.test_session(use_gpu=True) as sess:
actual_y, expected_y = sess.run([actual, expected])
print("actual_y = ", actual_y)
print("expected_y = ", expected_y)
tf_logging.info("actual_y = ", actual_y)
tf_logging.info("expected_y = ", expected_y)
self.assertTrue(np.array_equal(actual_y, expected_y))

def testFusedConvInt8(self):
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/kernel_tests/betainc_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def testBetaIncGrads(self):
tf_gout_t = math_ops.betainc(tf_ga_s, tf_gb_s, tf_gx_s)
err = gradient_checker.compute_gradient_error(
[tf_gx_s], [gx_s.shape], tf_gout_t, gx_s.shape)
print("betainc gradient err = %g " % err)
tf_logging.info("betainc gradient err = %g " % err)
self.assertLess(err, err_tolerance)

# Test broadcast gradient
Expand All @@ -181,7 +181,7 @@ def testBetaIncGrads(self):
tf_gout_t = math_ops.betainc(tf_ga_s, tf_gb_s, tf_gx_s)
err = gradient_checker.compute_gradient_error(
[tf_gx_s], [()], tf_gout_t, ga_s.shape)
print("betainc gradient err = %g " % err)
tf_logging.info("betainc gradient err = %g " % err)
self.assertLess(err, err_tolerance)


Expand Down
32 changes: 16 additions & 16 deletions tensorflow/python/kernel_tests/conv_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def _VerifyDilatedConvValues(self, tensor_in_sizes, filter_in_sizes, strides,
expected_values = self.evaluate(expected_results)
computed_values = self.evaluate(computed_results)
for e_value, c_value in zip(expected_values, computed_values):
print("expected = ", e_value)
print("actual = ", c_value)
tf_logging.info("expected = ", e_value)
tf_logging.info("actual = ", c_value)
self.assertAllClose(
e_value.flatten(), c_value.flatten(), atol=tolerance, rtol=1e-4)

Expand All @@ -337,8 +337,8 @@ def _VerifyValues(self, tensor_in_sizes, filter_in_sizes, strides, padding,
for i in range(len(tensors)):
conv = tensors[i]
value = values[i]
print("expected = ", expected)
print("actual = ", value)
tf_logging.info("expected = ", expected)
tf_logging.info("actual = ", value)
tol = 1e-5
if value.dtype == np.float16:
tol = 1e-3
Expand Down Expand Up @@ -547,8 +547,8 @@ def _RunAndVerifyBackpropInput(self, input_sizes, filter_sizes, output_sizes,
# "values" consists of two tensors for two backprops
value = self.evaluate(conv)
self.assertShapeEqual(value, conv)
print("expected = ", expected)
print("actual = ", value)
tf_logging.info("expected = ", expected)
tf_logging.info("actual = ", value)
self.assertArrayNear(expected, value.flatten(), err)

def _CompareBackpropInput(self, input_sizes, filter_sizes, output_sizes,
Expand Down Expand Up @@ -723,8 +723,8 @@ def _RunAndVerifyBackpropFilter(self, input_sizes, filter_sizes, output_sizes,
data_format=data_format)
value = self.evaluate(conv)
self.assertShapeEqual(value, conv)
print("expected = ", expected)
print("actual = ", value)
tf_logging.info("expected = ", expected)
tf_logging.info("actual = ", value)
self.assertArrayNear(expected, value.flatten(), 1e-5)

def _CompareBackFilter(self, input_sizes, filter_sizes, output_sizes,
Expand Down Expand Up @@ -912,8 +912,8 @@ def _RunAndVerifyBackpropInputDilation(self, input_sizes, filter_sizes,
value_2 = sess.run(conv_2)
self.assertShapeEqual(value, conv)
self.assertShapeEqual(value_2, conv_2)
print("expected = ", value_2)
print("actual = ", value)
tf_logging.info("expected = ", value_2)
tf_logging.info("actual = ", value)
self.assertArrayNear(value_2.flatten(), value.flatten(), err)

# Testing for backprops
Expand Down Expand Up @@ -965,8 +965,8 @@ def _RunAndVerifyBackpropFilterDilation(self, input_sizes, filter_sizes,
value_2 = sess.run(conv_2)
self.assertShapeEqual(value, conv)
self.assertShapeEqual(value_2, conv_2)
print("expected = ", value_2)
print("actual = ", value)
tf_logging.info("expected = ", value_2)
tf_logging.info("actual = ", value)
self.assertArrayNear(value_2.flatten(), value.flatten(), err)

def testConv2D2x2Depth3ValidBackpropFilterStride1x1Dilation2x1(self):
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def ConstructAndTestGradient(self, batch, input_rows, input_cols, filter_rows,
# since fp16 numerical gradients are too imprecise.
err = np.fabs(jacob_t - reference_jacob_t).max()

print("conv_2d gradient error = ", err)
tf_logging.info("conv_2d gradient error = ", err)
self.assertLess(err, 0.002)

def testInputGradientValidPaddingStrideOne(self):
Expand Down Expand Up @@ -1546,7 +1546,7 @@ def _VerifyValues(self, tensor_in_sizes, filter_in_sizes, stride, padding,
conv = nn_impl.depthwise_conv2d(
t1, t2, strides=[1, stride, stride, 1], padding=padding)
value = sess.run(conv)
print("value = ", value)
tf_logging.info("value = ", value)
self.assertArrayNear(expected, np.ravel(value), 1e-5)
self.assertShapeEqual(value, conv)

Expand Down Expand Up @@ -1668,7 +1668,7 @@ def _VerifyValues(self,
conv = array_ops.transpose(conv, [0, 2, 3, 1])

value = sess.run(conv)
print("value = ", value)
tf_logging.info("value = ", value)
self.assertArrayNear(expected, np.ravel(value), 1e-5)
self.assertShapeEqual(value, conv)

Expand Down Expand Up @@ -1826,7 +1826,7 @@ def benchmarkGPUConvStackFirst(self):
wall_time = time.time() - start
self.report_benchmark(
name="conv_stack_iter_%d" % iter_index, wall_time=wall_time)
print("conv_stack_iter_%d: %.4f" % (iter_index, wall_time))
tf_logging.info("conv_stack_iter_%d: %.4f" % (iter_index, wall_time))


def GetInceptionFwdTest(input_size, filter_size, stride, padding,
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/kernel_tests/pooling_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def _ConstructAndTestGradient(self,
output_sizes,
x_init_value=x_init_value,
delta=1e-2)
print("%s gradient error = " % func_name, err)
tf_logging.info("%s gradient error = " % func_name, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is broken, should be:
tf_logging.info("%s gradient error = %.4f" % (func_name, err))

self.assertLess(err, err_tolerance)

def _ConstructAndTestSecondGradient(self,
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def _ConstructAndTestSecondGradient(self,
input_sizes,
x_init_value=x_init_value,
delta=1e-2)
print("%s second-order gradient error = " % func_name, err)
tf_logging.info("%s second-order gradient error = " % func_name, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be:
tf_logging.info("%s second-order gradient error = %.4f" % (func_name, err))

self.assertLess(err, err_tolerance)

def _testMaxPoolGradValidPadding1_1(self, data_format, use_gpu):
Expand Down
12 changes: 6 additions & 6 deletions tensorflow/tools/quantization/quantize_graph_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def are_tensors_near(a, b, tolerance):
flat_a = a.flatten()
flat_b = b.flatten()
if len(flat_a) != len(flat_b):
print("Tensors are different sizes: " + str(len(flat_a)) + " vs " + str(
len(flat_b)))
tf_logging.info("Tensors are different sizes: " + str(len(flat_a)) + " vs "
+ str(len(flat_b)))
return False
value_count = len(flat_a)
how_many_different = 0
Expand All @@ -140,10 +140,10 @@ def are_tensors_near(a, b, tolerance):
if how_many_different == 0:
return True
else:
print("Tensors have {0} different values ({1}%), with mean difference"
" {2} and mean absolute difference {3}".format(
how_many_different, proportion_different * 100, mean_difference,
mean_abs_difference))
tf_logging.info("Tensors have {0} different values ({1}%), with mean"
" difference {2} and mean absolute difference {3}".format(
how_many_different, proportion_different * 100,
mean_difference, mean_abs_difference))
return False


Expand Down