Pytorch训练SSD时出现的警告和错误(更新中)
1. ERROR : assert win is not None, 'Must define a window to update' AssertionError: Must define a wind(train.py中修改)
上图是修改完后的样子,将这段函数上面代码中的epoch+=1挪到 “if args.visdom:" 函数下,并把update_vis_plot括号中的内容替换成图片中的内容,问题解决,具体可参考https://github.com/amdegroot/ssd.pytorch/issues/234
2. VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
/home/bb622/ssd.pytorch-master/utils/augmentations.py:239: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
mode = random.choice(self.sample_options)
出现这种错误要么降低numpy版本,降到19.0以下,要么添加dtypt = object(尝试了几次,没有成功,可能添加dtype的地方不对)
3. UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.(train.py中修改)
修改前
if args.cuda:
images = Variable(images.cuda())
targets = [Variable(ann.cuda(), volatile=True) for ann in targets]
else:
images = Variable(images)
targets = [Variable(ann, volatile=True) for ann in targets]
修改后
if args.cuda:
images = Variable(images.cuda())
with torch.no_grad():
targets = [Variable(ann.cuda()) for ann in targets]
else:
images = Variable(images)
with torch.no_grad():
targets = [Variable(ann) for ann in targets]
4. UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
warnings.warn(warning.format(ret))
将 multibox_loss.py函数中的90行和111行的
loss_l = F.smooth_l1_loss(loc_p, loc_t, size_average=False)改为
loss_l = F.smooth_l1_loss(loc_p, loc_t, reduction='sum')