torch.maximum¶ torch.maximum(input, other, *, out=None) → Tensor¶ 計算 input 和 other 的逐元素最大值。 注意 如果比較的元素之一是 NaN,則返回該元素。具有複數 dtype 的 Tensor 不支援 maximum()。 引數 input (Tensor) – 輸入 Tensor。 other (Tensor) – 第二個輸入 Tensor 關鍵字引數 out (Tensor, 可選) – 輸出 Tensor。 示例 >>> a = torch.tensor((1, 2, -1)) >>> b = torch.tensor((3, 0, 4)) >>> torch.maximum(a, b) tensor([3, 2, 4])