simple-ssd-for-beginners icon indicating copy to clipboard operation
simple-ssd-for-beginners copied to clipboard

Error in Multibox Loss for Custom Dataset

Open madiltalay opened this issue 4 years ago • 0 comments

Hi, I am using this implementation for a custom dataset. While running the training loop, I get an error from the line: loc_loss, cls_loss = criterion(p_loc, p_label, gt_boxes, gt_labels) The error is:

/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce, reduction) 1836 .format(input.size(0), target.size(0))) 1837 if dim == 2: -> 1838 ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index) 1839 elif dim == 4: 1840 ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)

RuntimeError: invalid argument 2: non-empty vector or matrix expected at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:31

I thought that there might be some images with no objects and so I tried to filter them out by: for i , (img, boxes) in enumerate(dataloader): if len(boxes)==0: continue But the error still persists. Can you please guide. Thanks

madiltalay avatar Mar 10 '20 06:03 madiltalay