評價此頁

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