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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值