捷徑

torch.maximum

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

計算 inputother 的元素級最大值。

注意

如果正在比較的元素之一是 NaN,則返回該元素。maximum() 不支援具有複數 dtype 的張量。

參數 (Parameters)
  • input (Tensor) – 輸入張量 (input tensor)。

  • other (Tensor) – 第二個輸入張量 (the second input tensor)

關鍵字參數 (Keyword Arguments)

out (Tensor, optional) – 輸出張量 (the output tensor),可選 (optional)。

範例 (Example)

>>> a = torch.tensor((1, 2, -1))
>>> b = torch.tensor((3, 0, 4))
>>> torch.maximum(a, b)
tensor([3, 2, 4])

文件

存取 PyTorch 的完整開發者文件

檢視文件 (View Docs)

教學 (Tutorials)

取得初學者和進階開發者的深入教學

檢視教學 (View Tutorials)

資源 (Resources)

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

檢視資源 (View Resources)