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

PyTorch torch.atan2 function

PyTorch torch.atan2 function


PyTorch torch reference manual PyTorch torch reference manual

torch.atan2 is a function in PyTorch used to compute the element-wise two-argument arctangent (arctangent2). It computes the angle from two coordinate values (y, x); the returned value is in radians, ranging over [-pi, pi].

Function definition

torch.atan2(input, other, out=None)

Parameter Description


Usage examples

Example

import

torch

Creating tensors

y

=

torch.

tensor

(

[

0.0

,

1.0

,

1.0

,

1.0

]

)

x

=

torch.

tensor

(

[

1.0

,

0.0

,

0.0

,

1.0

]

)

Compute the two-argument arctangent

result

=

torch.

atan2

(

y

,

x

)

print

(

result

)

The output is:

tensor([ 0.0000,  1.5708, -1.5708,  2.3562])


PyTorch torch reference manual PyTorch torch reference manual