Description
rps@rps:~/桌面/ssd.pytorch$ python3 train.py
/home/rps/桌面/ssd.pytorch/ssd.py:34: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad():
instead.
self.priors = Variable(self.priorbox.forward(), volatile=True)
/home/rps/桌面/ssd.pytorch/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...
train.py:214: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
init.xavier_uniform(param)
Loading the dataset...
Training SSD on: VOC0712
Using the specified args:
Namespace(basenet='vgg16_reducedfc.pth', batch_size=32, cuda=True, dataset='VOC', dataset_root='/home/rps/data/VOCdevkit/', gamma=0.1, lr=0.001, momentum=0.9, num_workers=4, resume=None, save_folder='weights/', start_iter=0, visdom=False, weight_decay=0.0005)
train.py:169: 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 "train.py", line 255, in
train()
File "train.py", line 178, in train
loss_l, loss_c = criterion(out, targets)
File "/home/rps/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/rps/桌面/ssd.pytorch/layers/modules/multibox_loss.py", line 97, in forward
loss_c[pos] = 0 # filter out pos boxes for now
RuntimeError: The shape of the mask [32, 8732] at index 0 does not match the shape of the indexed tensor [279424, 1] at index 0
anyone helps,please...
Activity
isaactalx commentedon Jun 4, 2018
I have the same error.Using Pytorch0.4+python3.5.
bobo0810 commentedon Jun 7, 2018
python3.5 and pytorch 0.3.0 no problem
xscjun commentedon Jun 7, 2018
I have the same error,if I switch the lines 96,97
loss_c = loss_c.view(num, -1)
loss_c[pos] = 0
in multibox_loss.py, this error disappear.
But come with another error :
"File "/home/.../ssd.pytorch/layers/modules/multibox_loss.py", line 115, in forward
loss_l /= N
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument #3 'other'"
The type of tensor is not match, how can I fix it ?
slomrafgrav commentedon Jun 8, 2018
@xscjun change line:
N = num_pos.data.sum()
to:
N = num_pos.data.sum().double()
loss_l = loss_l.double()
loss_c = loss_c.double()
this should work
gtwell commentedon Jul 25, 2018
Anyone has solved this problem? help me tks.
Lin-Zhipeng commentedon Sep 27, 2018
The “pos” -> torch.Size([32, 8732])
The “loss_c ” ->torch.Size([279424, 1])
when I add one line as :
Then it worked.
zxt-triumph commentedon Nov 1, 2018
i have the same error, and how did you solve it finally?
zxt-triumph commentedon Nov 1, 2018
i have the same error, so how could you figure it out finally?
matthewarthur commentedon Nov 7, 2018
What file should be updated?
queryor commentedon Nov 12, 2018
change the data type of N to FloatTensor.
usherbob commentedon Nov 12, 2018
You may try to update your file
/home/.../ssd.pytorch/layers/modules/multibox_loss.py
, and add one line as @LZP4GitHub said above.subicWang commentedon Nov 13, 2018
@usherbob python3.6+pytorch0.4.1, I added "loss_c = loss_c.view(pos.size()[0], pos.size()[1]) #add line", but I have another issue. RuntimeError: copy_if failed to synchronize: device-side assert triggered
subicWang commentedon Nov 14, 2018
Finally, I succeeded.
step1: switch the two lines 97,98:
loss_c = loss_c.view(num, -1)
loss_c[pos] = 0 # filter out pos boxes for now
step2: change the line144 N = num_pos.data.sum() to
N = num_pos.data.sum().double()
loss_l = loss_l.double()
loss_c = loss_c.double()
48 remaining items