PyTorch torch.real Function
PyTorch torch Reference Manual
torch.realis a function in PyTorch used to return the real part of a complex tensor.
Function Definition
torch.real(input)
Usage Example
Example
import torch
# Return the real part of the complex tensor
x = torch.tensor([1+2j, 3+4j, 5+6j])
result = torch.real(x)
print(result)
# Return the real part of the complex tensor
x = torch.tensor([1+2j, 3+4j, 5+6j])
result = torch.real(x)
print(result)
Other Extensions