torch.maximum torch.maximum(input, other, *, out=None) → Tensor 计算input和other的元素-wise最大值。 计算input和other的元素级最大值。 注意 如果比较的元素中包含 NaN,则返回该元素。不支持使用 maximum() 对具有复数数据类型的张量进行操作。 参数 input (Tensor) – 需要输入的张量。 other (Tensor) – 输入的第二个张量 关键字参数 out (Tensor, 可选) – 指定输出张量。 示例: >>> a = torch.tensor((1, 2, -1)) >>> b = torch.tensor((3, 0, 4)) >>> torch.maximum(a, b) tensor([3, 2, 4])