Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: too many indices for tensor of dimension 2 #19

Open
Halo754 opened this issue Jul 6, 2021 · 2 comments
Open

IndexError: too many indices for tensor of dimension 2 #19

Halo754 opened this issue Jul 6, 2021 · 2 comments

Comments

@Halo754
Copy link

Halo754 commented Jul 6, 2021

Setting up a new session...
E:\MyPaper\TargetDetection\Ours_SSD\Code\SSD\ssd_-repulsion_-loss\ssd.py:35: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
self.priors = Variable(self.priorbox.forward(), volatile=True)
E:\MyPaper\TargetDetection\Ours_SSD\Code\SSD\ssd_-repulsion_-loss\layers\modules\l2norm.py:17: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
init.constant(self.weight,self.gamma)
Loading base network...
Initializing weights...
Loading the dataset...
Training SSD on: VOC0712
Using the specified args:
Namespace(basenet='vgg16_reducedfc.pth', batch_size=16, cuda=True, dataset='VOC', dataset_root='E:\MyPaper\TargetDetection\Ours_SSD\Code\SSD\ssd_-repulsion_-loss\data/VOCdevkit/', gamma=0.1, lr=0.0001, momentum=0.9, num_workers=0, resume=None, save_folder='weights/', start_iter=0, visdom=False, weight_decay=0.0005)
E:\MyPaper\TargetDetection\Ours_SSD\Code\SSD\ssd_-repulsion_-loss\utils\augmentations.py:238: 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)
E:/MyPaper/TargetDetection/Ours_SSD/Code/SSD/ssd_-repulsion_-loss/train.py:178: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
targets = [Variable(ann.cuda(), volatile=True) for ann in targets]
Traceback (most recent call last):
File "E:/MyPaper/TargetDetection/Ours_SSD/Code/SSD/ssd_-repulsion_-loss/train.py", line 265, in
train()
File "E:/MyPaper/TargetDetection/Ours_SSD/Code/SSD/ssd_-repulsion_-loss/train.py", line 187, in train
loss_l, loss_l_repul, loss_c = criterion(out, targets)
File "D:\anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "E:\MyPaper\TargetDetection\Ours_SSD\Code\SSD\ssd_-repulsion_-loss\layers\modules\multibox_loss.py", line 97, in forward
priors = priors[pos_idx].view(-1, 4)
IndexError: too many indices for tensor of dimension 2

@SeokminJang
Copy link

SeokminJang commented Jul 23, 2021

#1 (comment)

check this comment

@hskfn
Copy link

hskfn commented Jan 19, 2024

priors = torch.concat([priors[pos_idx[index]] for index in range(pos_idx.shape[0])]).view(-1, 4)
torch=1.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants