Pytorch Torch Isreal
# PyTorch torch.isreal Function
* * Pytorch torch Reference Manual](#)
`torch.isreal` is a function in PyTorch used to check if a number is real. It returns a boolean tensor where each element is `True` if it is a real number (not a complex number).
### Function Definition
torch.isreal(input)
* * *
## Usage Example
## Example
import torch
# Create a tensor containing real and complex numbers
x = torch.tensor([1.0,2+3j,4.0,5+1j])
# Check if Real
result = torch.isreal(x)
print(result)
The output result is:
tensor([True, False, True, False])
* * Pytorch torch Reference Manual](#)
YouTip