diff --git a/RELEASE.md b/RELEASE.md index d2b502d03cf234..e220662fedca4b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -53,7 +53,8 @@ made `tf.sparse_split` require keyword arguments. * Deprecated `tf.concat` operator. Please switch to use `tf.concat_v2` for now. In the Beta release, we will update `tf.concat` to match argument order of - `tf.concat_v2. + `tf.concat_v2`. + * `tf.complex_abs` has been removed. `tf.abs` should be used instead. # Release 0.12.0 diff --git a/tensorflow/contrib/linalg/python/ops/linear_operator_matrix.py b/tensorflow/contrib/linalg/python/ops/linear_operator_matrix.py index fc5d51e210136a..7ca18450d1e438 100644 --- a/tensorflow/contrib/linalg/python/ops/linear_operator_matrix.py +++ b/tensorflow/contrib/linalg/python/ops/linear_operator_matrix.py @@ -172,11 +172,7 @@ def _log_abs_determinant(self): if self._is_spd: diag = array_ops.matrix_diag_part(self._chol) return 2 * math_ops.reduce_sum(math_ops.log(diag), reduction_indices=[-1]) - - if self.dtype.is_complex: - abs_det = math_ops.complex_abs(self.determinant()) - else: - abs_det = math_ops.abs(self.determinant()) + abs_det = math_ops.abs(self.determinant()) return math_ops.log(abs_det) def _solve(self, rhs, adjoint=False): diff --git a/tensorflow/contrib/linalg/python/ops/linear_operator_util.py b/tensorflow/contrib/linalg/python/ops/linear_operator_util.py index 06140ef4a27a0b..a2ba8acbd67d1d 100644 --- a/tensorflow/contrib/linalg/python/ops/linear_operator_util.py +++ b/tensorflow/contrib/linalg/python/ops/linear_operator_util.py @@ -39,14 +39,8 @@ def assert_no_entries_with_modulus_zero( with ops.name_scope(name, values=[x]): x = ops.convert_to_tensor(x, name="x") dtype = x.dtype.base_dtype - - if dtype.is_complex: - should_be_nonzero = math_ops.complex_abs(x) - else: - should_be_nonzero = math_ops.abs(x) - + should_be_nonzero = math_ops.abs(x) zero = ops.convert_to_tensor(0, dtype=dtype.real_dtype) - return check_ops.assert_less(zero, should_be_nonzero, message=message) diff --git a/tensorflow/python/kernel_tests/cwise_ops_test.py b/tensorflow/python/kernel_tests/cwise_ops_test.py index 79ec1ab62790ed..a828273314cd68 100644 --- a/tensorflow/python/kernel_tests/cwise_ops_test.py +++ b/tensorflow/python/kernel_tests/cwise_ops_test.py @@ -372,7 +372,7 @@ def testComplex64Basic(self): 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 @@ def _compareBroadcastGradient(self, x): 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 1c2e67114bdb46..5b6238d1cd5df4 100644 --- a/tensorflow/python/ops/math_grad_test.py +++ b/tensorflow/python/ops/math_grad_test.py @@ -72,10 +72,7 @@ def _testGrad(self, shape, dtype=None, max_error=None, bias=None, sigma=None): dtype=dtype) with self.test_session(use_gpu=True): - if dtype in (tf.complex64, tf.complex128): - output = tf.complex_abs(value) - else: - output = tf.abs(value) + output = tf.abs(value) error = tf.test.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 0f7727ae686cc2..cb7f838f6db617 100644 --- a/tensorflow/python/ops/math_ops.py +++ b/tensorflow/python/ops/math_ops.py @@ -125,7 +125,6 @@ functions to your graph. @@complex -@@complex_abs @@conj @@imag @@real @@ -292,8 +291,8 @@ def abs(x, name=None): \\\\(y = |x|\\\\). Args: - x: A `Tensor` or `SparseTensor` of type `float32`, `float64`, `int32`, or - `int64`. + x: A `Tensor` or `SparseTensor` of type `float16`, `float32`, `float64`, + `complex64`, `complex128`, `int32`, `int64`, name: A name for the operation (optional). Returns: @@ -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.