栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3.

在运行pytorch版SSD目标检测网络https://github.com/amdegroot/ssd.pytorch时遇到这个错误
使用Detect类创建对象self.detect执行检测,Detect类继承自Function类,在pytorch1.3及以后的版本需要规定forward方法为静态方法,所以在pytorch1.3以上的版本执行出错。

解决方法:加forward

        if self.phase == "test":
            # output = self.detect(loc.view(loc.size(0), -1, 4), # 将网络的位置预测表示为(-1,4)形式torch.Size([1, 8732, 4])
            #     self.softmax(conf.view(conf.size(0), -1,self.num_classes)), # 将网络的置信度预测表示为(-1,5)形式torch.Size([1, 8732, 5])
            #     self.priors.type(type(x.data))                  # 先验anchor box,格式(x,y,w,h)
            # )
            ##########################################################           
            output=self.detect.forward(loc.view(loc.size(0), -1, 4),  
                                                self.softmax(conf.view(conf.size(0), 
                                                -1,self.num_classes)),          
                                                                      self.priors.type(type(x.data)) )        

thanks

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/714668.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号