PyTorch torch.angle 函数
torch.angle 是 PyTorch 中用于返回复数张量相位角(argument)的函数。返回值的单位为弧度,范围在 [-pi, pi] 之间。
函数定义
torch.angle(input, out=None)
使用示例
实例
import torch
# 创建复数张量
x = torch.tensor([1+1j, 1+0j, 0+1j, -1+0j])
# 返回相位角
result = torch.angle(x)
print(result)
# 创建复数张量
x = torch.tensor([1+1j, 1+0j, 0+1j, -1+0j])
# 返回相位角
result = torch.angle(x)
print(result)
输出结果为:
tensor([ 0.7854, 0.0000, 1.5708, 3.1416])

Pytorch torch 参考手册