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: The shape of the mask [12, 1] at index 1 does not match the shape of the indexed tensor [12, 24564] at index 1 #201

Open
weimengmeng1999 opened this issue Jun 27, 2021 · 2 comments

Comments

@weimengmeng1999
Copy link

Hi, I'm using my own dataset to train the model. But I got the following error when during training, which I have no idea what's wrong. I've checked all the datatype, and they are all the same as the ones in VOC and COCO. Could you please help me with it:

Traceback (most recent call last):
File "train.py", line 114, in
main()
File "train.py", line 105, in main
model = train(cfg, args)
File "train.py", line 44, in train
model = do_train(cfg, model, train_loader, optimizer, scheduler, checkpointer, device, arguments, args)
File "/home/tribta/SSD/ssd/engine/trainer.py", line 82, in do_train
loss_dict = model(images, targets=targets)
File "/home/tribta/miniconda3/envs/wmod/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/tribta/SSD/ssd/modeling/detector/ssd_detector.py", line 16, in forward
detections, detector_losses = self.box_head(features, targets)
File "/home/tribta/miniconda3/envs/wmod/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/tribta/SSD/ssd/modeling/box_head/box_head.py", line 25, in forward
return self._forward_train(cls_logits, bbox_pred, targets)
File "/home/tribta/SSD/ssd/modeling/box_head/box_head.py", line 31, in _forward_train
reg_loss, cls_loss = self.loss_evaluator(cls_logits, bbox_pred, gt_labels, gt_boxes)
File "/home/tribta/miniconda3/envs/wmod/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/tribta/SSD/ssd/modeling/box_head/loss.py", line 32, in forward
mask = box_utils.hard_negative_mining(loss, labels, self.neg_pos_ratio)
File "/home/tribta/SSD/ssd/utils/box_utils.py", line 122, in hard_negative_mining
loss[pos_mask] = -math.inf
IndexError: The shape of the mask [12, 1] at index 1 does not match the shape of the indexed tensor [12, 24564] at index 1

@palealice
Copy link

me too

@yongsenli
Copy link

me too,so,how can i do for this?

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