amdegroot / ssd.pytorch

A PyTorch Implementation of Single Shot MultiBox Detector
MIT License
5.14k stars 1.74k forks source link

this line is wrong, tensor used as index while the dim do not same #292

Open caijch opened 5 years ago

caijch commented 5 years ago

ayers/modules/multibox_loss.py

   # Hard Negative Mining
    loss_c[pos] = 0  # filter out pos boxes for now
    loss_c = loss_c.view(num, -1)

should be as loss_c = loss_c.view(num, -1) loss_c[pos] = 0 # filter out pos boxes for now

kache1995 commented 5 years ago

I also find this problem,but I don't know whether your solution is correct.

alexander-pv commented 5 years ago

ayers/modules/multibox_loss.py

   # Hard Negative Mining
    loss_c[pos] = 0  # filter out pos boxes for now
    loss_c = loss_c.view(num, -1)

should be as loss_c = loss_c.view(num, -1) loss_c[pos] = 0 # filter out pos boxes for now

This is the right solution.

IceMirror1995 commented 5 years ago

should be as:

pos = pos.view(loss_c.shape) loss_c[pos] = 0 # filter out pos boxes for now pos = pos.view(num, -1)