RuntimeError: dimension out of range (expected to be in range of [-1, 0], but got 1)
Closed this issue · 1 comments
Hello I have a problem.
when train.py
==> Building model..
/home/gt/torchcv/torchcv/models/ssd/net.py:41: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
nn.init.constant(self.weight, scale)
==> Preparing dataset..
Epoch: 0
Traceback (most recent call last):
File "/home/gt/torchcv/examples/ssd/train.py", line 148, in
train(epoch)
File "/home/gt/torchcv/examples/ssd/train.py", line 99, in train
for batch_idx, (inputs, loc_targets, cls_targets) in enumerate(trainloader):
File "/home/gt/anaconda3/envs/temp3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 286, in next
return self._process_next_batch(batch)
File "/home/gt/anaconda3/envs/temp3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File "/home/gt/anaconda3/envs/temp3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/gt/anaconda3/envs/temp3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/gt/torchcv/torchcv/datasets/listdataset.py", line 83, in getitem
img, boxes, labels = self.transform(img, boxes, labels)
File "/home/gt/torchcv/examples/ssd/train.py", line 63, in transform_train
boxes, labels = box_coder.encode(boxes, labels)
File "/home/gt/torchcv/torchcv/models/ssd/box_coder.py", line 78, in encode
index[mask] = ious[mask.nonzero().squeeze()].max(1)[1]
RuntimeError: dimension out of range (expected to be in range of [-1, 0], but got 1)
I dont' know what to do..
Please give me a advice.
After change it to ious[mask].max(1)[1], it works.