I create a class that inherited from nn.Module. And I used a existing function nms.
It used index_select().
But I encounter this error:
RuntimeError Traceback (most recent call last)
~/experiment/ssd.pytorch-master/train_association_lstm.py in ()
259
260 if name == ‘main’:
–> 261 train()~/experiment/ssd.pytorch-master/train_association_lstm.py in train()
179 # print(images.shape)
180 # print(targets)
–> 181 out = net(images,targets)
182 # backprop
183 optimizer.zero_grad()~/anaconda2/envs/gluon/lib/python3.5/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
489 result = self._slow_forward(*input, **kwargs)
490 else:
–> 491 result = self.forward(*input, **kwargs)
492 for hook in self._forward_hooks.values():
493 hook_result = hook(self, input, result)~/experiment/ssd.pytorch-master/association_lstm.py in forward(self, x, targets)
113 conf.view(conf.size(0), -1, self.num_classes),
114 self.priors.type(type(x.data)), # default boxes
–> 115 targets
116 )
117 else:~/anaconda2/envs/gluon/lib/python3.5/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
489 result = self._slow_forward(*input, **kwargs)
490 else:
–> 491 result = self.forward(*input, **kwargs)
492 for hook in self._forward_hooks.values():
493 hook_result = hook(self, input, result)~/experiment/ssd.pytorch-master/layers/functions/detection.py in forward(self, loc_data, conf_data, prior_data, targets)
155
156 # idx of highest scoring and non-overlapping boxes per class
–> 157 ids, count = nms(boxes, scores, self.nms_thresh, self.top_k)
158 output.append(
159 torch.cat((scores[ids[:count]].unsqueeze(1),~/experiment/ssd.pytorch-master/layers/box_utils.py in nms(boxes, scores, overlap, top_k)
223 idx = Variable(idx) # add for autograde this version
224 # load bboxes of next highest vals
–> 225 torch.index_select(x1, 0, idx, out=xx1)
226 torch.index_select(y1, 0, idx, out=yy1)
227 torch.index_select(x2, 0, idx, out=xx2)RuntimeError: index_select(): functions with out=… arguments don’t support automatic differentiation, but one of the arguments requires grad.
The nms function i used here
.
Why there is a error here?
How can I fix it?