1.修改ssd中的代码
if phase == 'test':
self.softmax = nn.Softmax(dim=-1)
self.detect = Detect(num_classes, 0, 200, 0.01, 0.45)
改成
if phase == 'test':
self.softmax = nn.Softmax()
self.detect = Detect()
另外该文件下的def forward()方法中的:
if self.phase == "test":
output = self.detect(
loc.view(loc.size(0), -1, 4), # loc preds
self.softmax(conf.view(conf.size(0), -1,
self.num_classes)), # conf preds
self.priors.type(type(x.data)) # default boxes
)
改为:
if self.phase == "test":
output = self.detect.apply(self.num_classes, 0, 200, 0.01, 0.45,
loc.view(loc.size(0), -1, 4), # loc preds
self.softmax(conf.view(-1,
self.num_classes)), # conf preds
self.priors.type(type(x.data)) # default boxes
)
2.修改layers中的function中的detection.py代码
def forward(self, num_classes, bkg_label, top_k, conf_thresh, nms_thresh, loc_data, conf_data, prior_data):
|
loc_data: (tensor) Loc preds from loc layers
|
Shape: [batch,num_priors*4]
|
conf_data: (tensor) Shape: Conf preds from conf layers
|
Shape: [batch*num_priors,num_classes]
|
prior_data: (tensor) Prior boxes and variances from priorbox layers
|
self.num_classes = num_classes
|
self.background_label = bkg_label
|
# Parameters used in nms.
|
self.nms_thresh = nms_thresh
|
raise ValueError('nms_threshold must be non negative.')
|
self.conf_thresh = conf_thresh
|
self.variance = cfg['variance']
|
num = loc_data.size(0) # batch size
|
num_priors = prior_data.size(0)
|
output = torch.zeros(num, self.num_classes, self.top_k, 5)
|
conf_preds = conf_data.view(num, num_priors,
|
self.num_classes).transpose(2, 1)
|
# Decode predictions into bboxes.
|
decoded_boxes = decode(loc_data[i], prior_data, self.variance)
|
# For each class, perform nms
|
conf_scores = conf_preds[i].clone()
|
for cl in range(1, self.num_classes):
|
c_mask = conf_scores[cl].gt(self.conf_thresh)
|
scores = conf_scores[cl][c_mask]
|
l_mask = c_mask.unsqueeze(1).expand_as(decoded_boxes)
|
boxes = decoded_boxes[l_mask].view(-1, 4)
|
# idx of highest scoring and non-overlapping boxes per class
|
ids, count = nms(boxes, scores, self.nms_thresh, self.top_k)
|
output[i, cl, :count] = \
|
torch.cat((scores[ids[:count]].unsqueeze(1),
|
flt = output.contiguous().view(num, -1, 5)
|
_, idx = flt[:, :, 0].sort(1, descending=True)
|
flt[(rank < self.top_k).unsqueeze(-1).expand_as(flt)].fill_(0)
|
return output
RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-相关推荐
- Pytorch版本过高产生的RuntimeError: Legacy autograd function with non-static forward method is deprecated.
前言 在尝试用ECO Lite做视频分类的时候,使用了作者的Pytorch实现,然而Pytorch实现是基于Pytorch0.4的,我自己的Pytorch版本是1.4,所以在跑模型的时候出现了一些问题 ...
- RuntimeError: Legacy autograd function with non-static forward method is deprecated.
显卡RTX3080 cuda 11.1 cudnn 8.0.5 python3.6.4 在使用pytorch1.0训练densefusion模型时报错,改用pytorch1.7,然后报上面的错误 Tr ...
- Please use new-style autograd function with static forward method
Please use new-style autograd function with static forward method Legacy autograd function with non- ...
- Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd
Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd ...
- Legacy autograd function with non-static forward method is deprecated
Legacy autograd function with non-static forward method is deprecated 在网络s3fd_atss_sapd 测试时发现这个问题, d ...
- Pytorch使用autograd.Function自定义拓展神经网络
我们知道CNN这类人工神经网络都基于BP算法进行优化,因此需要误差关于权重是连续可导的,这是可以运用BP算法的前提条件:也有一些网络不满足这个条件. 1.可导 对于可连续求导的神经网络构建时采用nn. ...
- Pytorch的自定义拓展:torch.nn.Module和torch.autograd.Function
参考链接:pytorch的自定义拓展之(一)--torch.nn.Module和torch.autograd.Function_LoveMIss-Y的博客-CSDN博客_pytorch自定义backw ...
- 自定义autograd function
在TSN代码中, segmentconsensus是一个自定义函数, 所以要写一下它对应的梯度运算 # tj : https://blog.csdn.net/tsq292978891/article/ ...
- 使用torch.autograd.function解决dist.all_gather不能反向传播问题
1. 问题来源 最近在用mmcv复现Partial FC模型,看到源码中,有单独写的前向反向传播,甚是疑惑- 源码: # Features all-gather total_features = to ...
- WPF error: does not contain a static 'Main' method suitable for an entry point
does not contain a static 'Main' method suitable for an entry point 在Visual Studio中删除App.xaml从别的位置拷贝 ...
最新文章
- ngx_http_redis_module配置使用
- 数据结构与算法—递归算法(从阶乘、斐波那契到汉诺塔的递归图解)
- 广州站长沙龙 MIP 问题及答案
- Centos7上kvm虚拟化自定义NAT网络
- SQL脚本修改数据库名称
- enlink请输入正确服务器地址,Enlink
- linux 复制指定类型,用Linux命令行实现删除和复制指定类型的文件
- jquery时期到计时插件
- 读书摘要——《凌波微步-软件开发警戒案例集》
- python : sha256 、ripemd160
- [每日一题] OCP1z0-047 :2013-07-27 外部表――不能被DML和建索引...................................16...
- C++:stack.pop() error: cannot initialize a variable of type ‘char‘ with an rvalue of type ‘void‘
- layer.prompt输入框改成laydate时间控件
- 简历中的“项目经验”该怎么写?
- 了解速率控制模式:什么是 CBR、VBR、CRF和Capped-CRF?
- 投资学U14 债券的估值和收益率 习题解读
- 利用google搜索自己的博客
- 在水处理控制系统中正确运用信号隔离器
- HIT CS:APP 计算机系统大作业 《程序人生-Hello’s P2P》
- 超好用的思维导图网站
热门文章
- 弹性分布式数据集RDD
- React的this.props.children
- pip和requests模块的安装
- 国外六大免费Linux备份工具
- RHEL 5服务篇—LAMP平台的部署及应用
- java中报错java.sql.Timestamp cannot be cast to java.sql.Date
- Ubuntu 安装tftp服务器
- 一些面试题目(网易游戏2011.10.15校园招聘会笔试题)
- 在图片上加入删除按钮
- javascript闭包(转)