Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.polar function

PyTorch torch.polar function


PyTorch torch reference manual PyTorch torch reference manual

torch.polar is a function in PyTorch used to create a complex tensor from polar coordinates.

Function definition

torch.polar(abs, angle)


Usage examples

Example

import

torch

Create the absolute value (magnitude) tensor

abs_val

=

torch.

tensor

(

[

1.0

,

2.0

,

3.0

]

)

Create the angle (in radians) tensor

angle

=

torch.

tensor

(

[

0.0

,

torch.

pi

/

2

,

torch.

pi

]

)

Create a complex tensor from polar coordinates

x

=

torch.

polar

(

abs_val

,

angle

)

print

(

x

)

print

(

"Absolute value:"

,

x.

abs

(

)

)

print

(

"Angle:"

,

x.

angle

(

)

)


PyTorch torch reference manual PyTorch torch reference manual