【发布时间】:2021-09-22 07:34:38
【问题描述】:
我在 Ubuntu 上使用 1.7.1 版本的 Pytorch,我尝试执行以下操作:
x = torch.tensor([float('nan'), float('inf'), -float('inf'), 3.14])
torch.nan_to_num(x)
但我收到此错误:
AttributeError: module 'torch' has no attribute 'nan_to_num'
但它确实存在于文档中,因为我只是从中复制了这两行。有人可以帮我吗?
【问题讨论】:
-
nan_to_num适用于 1.8+ -
更新 Pytorch,然后重试
标签: python pytorch attributeerror