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