捷徑

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, 可選) – 輸出張量。

範例

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

文件

取得 PyTorch 的完整開發者文件

檢視文件

教學

取得初學者和高級開發人員的深入教學

檢視教學

資源

尋找開發資源並取得問題解答

檢視資源