TUTORIALAI 与数据科学FETCHED

PyTorch torch.nextafter 函数

PyTorch torch.nextafter 函数 Pytorch torch 参考手册 torch.nextafter 是 PyTorch 中用于逐元素返回下一个可表示的浮点数的函数。 函数定义 torch.nextafter(input, other, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 返回下一个可表示的浮点数..

更新于 2026/7/16

教程详情页默认 noindex。

PyTorch torch.nextafter 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.nextafter 是 PyTorch 中用于逐元素返回下一个可表示的浮点数的函数。

函数定义

torch.nextafter(input, other, out=None)

使用示例

实例

import torch

# 返回下一个可表示的浮点数
x = torch.tensor([1.0, 2.0])
y = torch.tensor([2.0, 2.0])
result = torch.nextafter(x, y)
print(result)

Pytorch torch 参考手册 Pytorch torch 参考手册