From edb095c19fe782a366b5953cb4d679a06562a3b4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 20 Dec 2016 14:37:03 -0800 Subject: Replace all uses of tf.complex_abs with tf.abs and remove tf.complex_abs from the Python API. Change: 142598006 --- RELEASE.md | 2 ++ tensorflow/core/ops/math_ops.cc | 7 ------- tensorflow/python/kernel_tests/cwise_ops_test.py | 4 ++-- tensorflow/python/ops/math_grad_test.py | 5 +---- tensorflow/python/ops/math_ops.py | 26 ------------------------ 5 files changed, 5 insertions(+), 39 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 6674e43755..a8bbc7064b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -57,6 +57,8 @@ * tf.image.decode_jpeg by default uses the faster DCT method, sacrificing a little fidelity for improved speed. One can revert to the old behavior by specifying the attribute dct_method='INTEGER_ACCURATE'. +* `tf.complex_abs` has been removed from the Python interface. `tf.abs` + supports complex tensors and should be used instead. # Release 0.12.0 diff --git a/tensorflow/core/ops/math_ops.cc b/tensorflow/core/ops/math_ops.cc index 0406584953..81cacffe96 100644 --- a/tensorflow/core/ops/math_ops.cc +++ b/tensorflow/core/ops/math_ops.cc @@ -175,13 +175,6 @@ Given a tensor `x` of complex numbers, this operation returns a tensor of type `float` or `double` that is the absolute value of each element in `x`. All elements in `x` must be complex numbers of the form \\(a + bj\\). The absolute value is computed as \\( \sqrt{a^2 + b^2}\\). - -For example: - -``` -# tensor 'x' is [[-2.25 + 4.75j], [-3.25 + 5.75j]] -tf.complex_abs(x) ==> [5.25594902, 6.60492229] -``` )doc"); // Declares cwise unary operations signature: 't -> 't diff --git a/tensorflow/python/kernel_tests/cwise_ops_test.py b/tensorflow/python/kernel_tests/cwise_ops_test.py index 79ec1ab627..a828273314 100644 --- a/tensorflow/python/kernel_tests/cwise_ops_test.py +++ b/tensorflow/python/kernel_tests/cwise_ops_test.py @@ -372,7 +372,7 @@ class UnaryOpTest(test.TestCase): x = np.complex(1, 1) * np.arange(-3, 3).reshape(1, 3, 2).astype(np.complex64) y = x + 0.5 # no zeros - self._compareCpu(x, np.abs, math_ops.complex_abs) + self._compareCpu(x, np.abs, math_ops.abs) self._compareCpu(x, np.abs, _ABS) self._compareCpu(x, np.negative, math_ops.neg) self._compareCpu(x, np.negative, _NEG) @@ -1932,7 +1932,7 @@ class ComplexMakeRealImagTest(test.TestCase): epsilon = 1e-3 with self.test_session(): for args in [(x_, 0.), (0., x_)]: - z = math_ops.reduce_sum(math_ops.complex_abs(math_ops.complex(*args))) + z = math_ops.reduce_sum(math_ops.abs(math_ops.complex(*args))) jacob_t, jacob_n = gradient_checker.compute_gradient( x_, list(x.shape), z, [1], x_init_value=x, delta=epsilon) self.assertAllClose(jacob_t, jacob_n, rtol=epsilon, atol=epsilon) diff --git a/tensorflow/python/ops/math_grad_test.py b/tensorflow/python/ops/math_grad_test.py index 6678ae4e26..8b0bc6b4f1 100644 --- a/tensorflow/python/ops/math_grad_test.py +++ b/tensorflow/python/ops/math_grad_test.py @@ -77,10 +77,7 @@ class AbsOpTest(test.TestCase): shape, bias=bias), dtype=dtype) with self.test_session(use_gpu=True): - if dtype in (dtypes.complex64, dtypes.complex128): - output = math_ops.complex_abs(value) - else: - output = math_ops.abs(value) + output = math_ops.abs(value) error = gradient_checker.compute_gradient_error( value, shape, output, output.get_shape().as_list()) self.assertLess(error, max_error) diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py index 0f7727ae68..20b9e438a1 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -125,7 +125,6 @@ TensorFlow provides several operations that you can use to add complex number functions to your graph. @@complex -@@complex_abs @@conj @@imag @@real @@ -439,31 +438,6 @@ def erf(x, name=None): return gen_math_ops.erf(x, name=name) -def complex_abs(x, name=None): - r"""Computes the complex absolute value of a tensor. - - Given a tensor `x` of complex numbers, this operation returns a tensor of type - `float32` or `float64` that is the absolute value of each element in `x`. All - elements in `x` must be complex numbers of the form \\(a + bj\\). The - absolute value is computed as \\( \sqrt{a^2 + b^2}\\). - - For example: - - ``` - # tensor 'x' is [[-2.25 + 4.75j], [-3.25 + 5.75j]] - tf.complex_abs(x) ==> [5.25594902, 6.60492229] - ``` - - Args: - x: A `Tensor` of type `complex64` or `complex128`. - name: A name for the operation (optional). - - Returns: - A `Tensor` of type `float32` or `float64`. - """ - return gen_math_ops._complex_abs(x, Tout=x.dtype.real_dtype, name=name) - - def scalar_mul(scalar, x): """Multiplies a scalar times a `Tensor` or `IndexedSlices` object. -- cgit v1.2.3