【问题标题】:AttributeError: module 'torch' has no attribute 'inference_mode'AttributeError:模块“火炬”没有属性“推理模式”
【发布时间】:2021-11-14 04:33:43
【问题描述】:

我对 pytorch 很陌生,当我尝试运行我的 CNN 时,我遇到了错误: AttributeError: 模块 'torch' 没有属性 'inference_mode'。 有谁知道发生了什么?它在 Google colab 上工作,但在其他地方没有。

【问题讨论】:

  • 请提供失败的代码段。

标签: pytorch


【解决方案1】:

很可能是版本问题。

torch.inference_mode() 最近被添加到v1.9。确保您拥有正确的版本。

尝试打印torch.__version__ 以检查您的版本。

【讨论】:

  • 即使使用torch 1.9.0,我的问题仍然存在。我想我通过更新torchvision 修复了它
猜你喜欢
  • 2023-04-04
  • 2021-05-13
  • 2018-10-10
  • 2018-11-19
  • 2018-04-29
  • 2021-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多