PyTorch torch.real Function


Pytorch torch 参考手册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)

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions