[已解决]tourch.nn.modules.module.Mo

2022-09-20  本文已影响0人  Vincent_Rain

调试yolov5程序的时候报错,torch.nn.modules.module.ModuleAttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘

本机Anaconda3环境

本机环境

解决办法

根据网上的方式,通过修改torch的代码成功解决问题。

找到环境路径

进入在Anaconda3中创建的环境,如:

环境路径

找到对应文件

找到activation文件,如图:

activation.py 文件

修改代码

在438行,删除self.inplace

def forward(self, input: Tensor) -> Tensor:

# return F.hardswish(input, self.inplace)

 return F.hardswish(input)

代码位置

重新运行

关键环境,关键anaconda3,重新运行。

上一篇 下一篇

猜你喜欢

热点阅读