torch.atan2
- torch.atan2(x, y, *, out=None) → Tensor
-
计算$\text{input}_{i} / \text{other}_{i}$ 的元素级反正切,并考虑象限。返回一个新的张量,其中包含向量 $(\text{other}_{i}, \text{input}_{i})$ 和向量 $(1, 0)$ 之间的有符号角度(以弧度为单位)。需要注意的是,$\text{other}_{i}$ (第二个参数)是 x 坐标,而 $\text{input}_{i}$ (第一个参数)是 y 坐标。
代码中的
input
和other
形状必须是 可广播的。示例:
>>> a = torch.randn(4) >>> a tensor([ 0.9041, 0.0196, -0.3108, -2.4423]) >>> torch.atan2(a, torch.randn(4)) tensor([ 0.9833, 0.0811, -1.9743, -1.4151])