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

解决办法
根据网上的方式,通过修改torch的代码成功解决问题。
找到环境路径
进入在Anaconda3中创建的环境,如:

找到对应文件
找到activation文件,如图:

修改代码
在438行,删除self.inplace
def forward(self, input: Tensor) -> Tensor:
# return F.hardswish(input, self.inplace)
return F.hardswish(input)

重新运行
关键环境,关键anaconda3,重新运行。
网友评论