PyTorch torch.polar Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.polaris a function in PyTorch used to create complex tensors from polar coordinates.

Function Definition

torch.polar(abs, angle)

Usage Example

Example

import torch

# Create absolute value (magnitude) tensor
abs_val = torch.tensor([1.0, 2.0, 3.0])

# Create angle (radian) tensor
angle = torch.tensor([0.0, torch.pi/2, torch.pi])

# Create complex tensor from polar coordinates
x = torch.polar(abs_val, angle)

print(x)
print("Absolute value:", x.abs())
print("Angle:", x.angle())

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions