PyTorch torch.arctan2 function
PyTorch torch reference manual
torch.arctan2 is a function in PyTorch used to compute the element-wise two-argument arctangent (arctangent2), the same as torch.atan2 in functionality.
Function definition
torch.arctan2(input, other, out=None)
Parameter Description
input: Numerator tensor (y-coordinate)other: Denominator tensor (x-coordinate)out: the output tensor (optional)
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.
arctan2
(
y
,
x
)
(
result
)
The output is:
tensor([ 0.0000, 1.5708, -1.5708, 2.3562])