評價此頁

torch.maximum#

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

計算 inputother 的逐元素最大值。

注意

如果被比較的元素之一是 NaN,則返回該元素。 maximum() 不支援具有複雜資料型別的張量。

引數
  • input (Tensor) – 輸入張量。

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

關鍵字引數

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

示例

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