TUTORIALAI & dataFETCHED

PyTorch torch.polar 函数

PyTorch torch.polar 函数 Pytorch torch 参考手册 torch.polar 是 PyTorch 中用于从极坐标创建复数张量的函数。 函数定义 torch.polar(abs, angle) 使用示例 实例 [mycode4 type='python'] import torch # 创建绝对值(模)张量 abs_val = torch.tensor([1.0, 2..

Updated 7/16/2026

Tutorial detail pages default to noindex.

PyTorch torch.polar 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.polar 是 PyTorch 中用于从极坐标创建复数张量的函数。

函数定义

torch.polar(abs, angle)

使用示例

实例

import torch

# 创建绝对值(模)张量
abs_val = torch.tensor([1.0, 2.0, 3.0])

# 创建角度(弧度)张量
angle = torch.tensor([0.0, torch.pi/2, torch.pi])

# 从极坐标创建复数张量
x = torch.polar(abs_val, angle)

print(x)
print("绝对值:", x.abs())
print("角度:", x.angle())

Pytorch torch 参考手册 Pytorch torch 参考手册