评价此页

torch.nextafter#

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

Return the next floating-point value after input towards other, elementwise.

The shapes of input and other must be broadcastable.

参数
  • input (Tensor) – 第一个输入张量

  • other (Tensor) – 第二个输入张量

关键字参数

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

示例

>>> eps = torch.finfo(torch.float32).eps
>>> torch.nextafter(torch.tensor([1.0, 2.0]), torch.tensor([2.0, 1.0])) == torch.tensor([eps + 1, 2 - eps])
tensor([True, True])