1 torch.ge()

逐元素比较inputother,即是否 \( input >= other \)。

如果两个张量有相同的形状和元素值,则返回True ,否则 False。 第二个参数可以为一个数或与第一个参数相同形状和类型的张量。

torch.ge(input, other, out=None) → Tensor
参数 描述 返回值
input 待对比的张量 一个 torch.ByteTensor 张量,包含了每个位置的比较结果(是否 input >= other )。 返回类型: Tensor
other 对比的张量或float值
out 可选,输出张量。必须为ByteTensor或者与第一个参数tensor相同类型
  • 栗子:
>>> torch.ge(torch.Tensor([[1, 2], [3, 4]]), torch.Tensor([[1, 1], [4, 4]]))
 1  1
 0  1
[torch.ByteTensor of size 2x2]

2 torch.gt()

逐元素比较inputother , 即是否\( input > other \) 如果两个张量有相同的形状和元素值,则返回True ,否则 False。 第二个参数可以为一个数或与第一个参数相同形状和类型的张量。

torch.gt(input, other, out=None) → Tensor
参数 描述 返回值
input 待对比的张量 一个 torch.ByteTensor 张量,包含了每个位置的比较结果(是否 input >= other )。 返回类型: Tensor
other 对比的张量或float值
out 可选,输出张量。必须为ByteTensor或者与第一个参数tensor相同类型
  • 栗子:
>>> torch.gt(torch.Tensor([[1, 2], [3, 4]]), torch.Tensor([[1, 1], [4, 4]]))
 0  1
 0  0
[torch.ByteTensor of size 2x2]

3 torch.le()

逐元素比较inputother , 即是否\( input <= other \) 第二个参数可以为一个数或与第一个参数相同形状和类型的张量。

  • 栗子
>>> torch.le(torch.Tensor([[1, 2], [3, 4]]), torch.Tensor([[1, 1], [4, 4]]))
 1  0
 1  1
[torch.ByteTensor of size 2x2]

4 torch.lt()

逐元素比较inputother , 即是否 \( input < other \),第二个参数可以为一个数或与第一个参数相同形状和类型的张量。

torch.lt(input, other, out=None) → Tensor
  • 栗子
>>> torch.lt(torch.Tensor([[1, 2], [3, 4]]), torch.Tensor([[1, 1], [4, 4]]))
 0  0
 1  0
[torch.ByteTensor of size 2x2]

 

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐