评价此页

torch.gt#

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

计算 input>other\text{input} > \text{other} 逐元素进行比较。

第二个参数可以是数字或张量,其形状与第一个参数可广播

参数
  • input (Tensor) – 要比较的张量

  • other (Tensor or float) – 要比较的张量或值

关键字参数

out (Tensor, optional) – 输出张量。

返回

一个布尔张量,在 input 大于 other 的位置为 True,否则为 False。

示例

>>> torch.gt(torch.tensor([[1, 2], [3, 4]]), torch.tensor([[1, 1], [4, 4]]))
tensor([[False, True], [False, False]])