评价此页

torch.atan2#

torch.atan2(input: Tensor, other: Tensor, *, out: Optional[Tensor]) Tensor#

元素级的反正切函数,计算 inputi/otheri\text{input}_{i} / \text{other}_{i} 的反正切,并考虑了象限。返回一个新张量,其中包含向量 (otheri,inputi)(\text{other}_{i}, \text{input}_{i}) 和向量 (1,0)(1, 0) 之间的有符号角度(以弧度为单位)。(注意,第二个参数 otheri\text{other}_{i} 是 x 坐标,而第一个参数 inputi\text{input}_{i} 是 y 坐标)。

inputother 的形状必须是 可广播的

参数
  • input (Tensor) – 第一个输入张量

  • other (Tensor) – 第二个输入张量

关键字参数

out (Tensor, optional) – 输出张量。

示例

>>> 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])