Ssd.pytorch: Training error in multibox_loss.py

Created on 18 Dec 2017  路  5Comments  路  Source: amdegroot/ssd.pytorch

I am very new about Pytorch, and when I use the default setting, and train the voc firstly, get the following error:


Loading base network...
Initializing weights...
Loading Dataset...
Training SSD on VOC0712
Traceback (most recent call last):
File "train.py", line 231, in
train()
File "train.py", line 183, in train
loss_l, loss_c = criterion(out, targets)
File "/home/mengyong/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 325, in __call__
result = self.forward(input, *kwargs)
File "/home/mengyong/Detection/ssd.pytorch/layers/modules/multibox_loss.py", line 83, in forward
num_pos = pos.sum(keepdim=True)
RuntimeError: sum() missing 1 required positional arguments: "dim"


Can you help me solve the problem, very thanks!

Most helpful comment

Yes, just set the error line
num_pos = pos.sum(keepdim=True)
as the new coding
num_pos = pos.sum(dim=1, keepdim=True)
all thing will be OK!
Importantly, you will find num_pos is defined newly in the following line, so you can just remove it, things also will be OK

All 5 comments

I met the same problem, have you solved it?

Yes, just set the error line
num_pos = pos.sum(keepdim=True)
as the new coding
num_pos = pos.sum(dim=1, keepdim=True)
all thing will be OK!
Importantly, you will find num_pos is defined newly in the following line, so you can just remove it, things also will be OK

@lmingyin Thanks!

Thanks for catching this, having a hard time keeping up with PyTorch updates!

@lmingyin hello,,i have some training issues?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikejmills picture mikejmills  路  6Comments

DHZS picture DHZS  路  5Comments

isalirezag picture isalirezag  路  5Comments

ohnabe picture ohnabe  路  6Comments

LAWSSSS picture LAWSSSS  路  4Comments