模块 'torch' 没有属性 'linalg'

module 'torch' has no attribute 'linalg'

我在使用 optimizer.step(model.closure) 更新参数时收到此错误 AttributeError: module 'torch' has no attribute 'linalg'。 我正在使用 Pytorch 版本 1.4.0.

linalg 仅在更高版本(1.7.0)上引入到 pytorch。更新pytorch再试一次。

我已经解决了这个问题,将 PyTorch 更新到 (1.8.1)