【发布时间】:2021-11-14 04:33:43
【问题描述】:
我对 pytorch 很陌生,当我尝试运行我的 CNN 时,我遇到了错误: AttributeError: 模块 'torch' 没有属性 'inference_mode'。 有谁知道发生了什么?它在 Google colab 上工作,但在其他地方没有。
【问题讨论】:
-
请提供失败的代码段。
标签: pytorch
我对 pytorch 很陌生,当我尝试运行我的 CNN 时,我遇到了错误: AttributeError: 模块 'torch' 没有属性 'inference_mode'。 有谁知道发生了什么?它在 Google colab 上工作,但在其他地方没有。
【问题讨论】:
标签: pytorch
很可能是版本问题。
torch.inference_mode() 最近被添加到v1.9。确保您拥有正确的版本。
尝试打印torch.__version__ 以检查您的版本。
【讨论】:
torchvision 修复了它