PyTorch torch.angle Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.angleIt is a function in PyTorch used to return the phase angle (argument) of a complex tensor. The returned value is in radians, with a range of [-pi, pi].

Function Definition

torch.angle(input, out=None)

Usage Example

Example

import torch

# Create a complex tensor
x = torch.tensor([1+1j, 1+0j, 0+1j, -1+0j])

# Return the phase angle
result = torch.angle(x)
print(result)

The output result is:

tensor([ 0.7854,  0.0000,  1.5708, 3.1416])

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions