pytorch / 2 / generated / torch.isreal.html

torch.isreal

torch.isreal(input) → Tensor

Returns a new tensor with boolean elements representing if each element of input is real-valued or not. All real-valued types are considered real. Complex values are considered real when their imaginary part is 0.

Parameters

input (Tensor) – the input tensor.

Returns

A boolean tensor that is True where input is real and False elsewhere

Example:

>>> torch.isreal(torch.tensor([1, 1+1j, 2+0j]))
tensor([True, False, True])

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.isreal.html