Closed
Description
My environment is cuda9.0, python3.6, pytorch0.4. I use pascal_voc dataset.
When I run trainval_net.py, I got this error. How to solve this?
labels = gt_boxes[:, :, 4].contiguous().view(-1).index(offset.view(-1)).view(batch_size, -1) TypeError: index(): argument 'indices' (position 1) must be tuple of Tensors, not Tensor
The error line is in class _ProposalTargetLayer(nn.Module),
def _sample_rois_pytorch(self, all_rois, gt_boxes, fg_rois_per_image, rois_per_image, num_classes):
` def _sample_rois_pytorch(self, all_rois, gt_boxes, fg_rois_per_image, rois_per_image, num_classes):
"""Generate a random sample of RoIs comprising foreground and background
examples.
"""
# overlaps: (rois x gt_boxes)
overlaps = bbox_overlaps_batch(all_rois, gt_boxes)
max_overlaps, gt_assignment = torch.max(overlaps, 2)
batch_size = overlaps.size(0)
num_proposal = overlaps.size(1)
num_boxes_per_img = overlaps.size(2)
offset = torch.arange(0, batch_size)*gt_boxes.size(1)
offset = offset.view(-1, 1).type_as(gt_assignment) + gt_assignment
labels = gt_boxes[:, :, 4].contiguous().view(-1).index(offset.view(-1)).view(batch_size, -1)`
Activity
gullalc commentedon Jul 16, 2018
Use index() like this:
index((offset.view(-1),))
buyi1128 commentedon Jul 17, 2018
@gullalc Thanks a lot. I used [] replace index(), it also works for me.