评价此页

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