評價此頁

torch.hypot#

torch.hypot(input, other, *, out=None) Tensor#

給定直角三角形的兩條直角邊,返回其斜邊。

outi=inputi2+otheri2\text{out}_{i} = \sqrt{\text{input}_{i}^{2} + \text{other}_{i}^{2}}

inputother 的形狀必須是 可廣播的

引數
  • input (Tensor) – 第一個輸入張量

  • other (Tensor) – 第二個輸入張量

關鍵字引數

out (Tensor, optional) – 輸出張量。

示例

>>> a = torch.hypot(torch.tensor([4.0]), torch.tensor([3.0, 4.0, 5.0]))
tensor([5.0000, 5.6569, 6.4031])