r"""Returns the imaginary part of a complex (or real) tensor. Given a tensor `input`, this operation returns a tensor of type `float` that is the imaginary part of each element in `input` considered as a complex number. If `input` is real, a tensor of all zeros is returned. For example:
(input, name=None)
| 543 | @deprecation.deprecated_endpoints("imag") |
| 544 | @dispatch.add_dispatch_support |
| 545 | def imag(input, name=None): |
| 546 | r"""Returns the imaginary part of a complex (or real) tensor. |
| 547 | |
| 548 | Given a tensor `input`, this operation returns a tensor of type `float` that |
| 549 | is the imaginary part of each element in `input` considered as a complex |
| 550 | number. If `input` is real, a tensor of all zeros is returned. |
| 551 | |
| 552 | For example: |
| 553 | |
| 554 | ```python |
| 555 | x = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j]) |
| 556 | tf.math.imag(x) # [4.75, 5.75] |
| 557 | ``` |
| 558 | |
| 559 | Args: |
| 560 | input: A `Tensor`. Must be one of the following types: `float`, `double`, |
| 561 | `complex64`, `complex128`. |
| 562 | name: A name for the operation (optional). |
| 563 | |
| 564 | Returns: |
| 565 | A `Tensor` of type `float32` or `float64`. |
| 566 | """ |
| 567 | with ops.name_scope(name, "Imag", [input]) as name: |
| 568 | input = ops.convert_to_tensor(input, name="input") |
| 569 | if input.dtype.is_complex: |
| 570 | return gen_math_ops.imag(input, Tout=input.dtype.real_dtype, name=name) |
| 571 | else: |
| 572 | return array_ops.zeros_like(input) |
| 573 | |
| 574 | |
| 575 | @tf_export("math.angle", v1=["math.angle", "angle"]) |