lufficc / SSD

High quality, fast, modular reference implementation of SSD in PyTorch
MIT License
1.52k stars 384 forks source link

Puzzled over the loss #187

Closed smartadpole closed 3 years ago

smartadpole commented 3 years ago

I am puzzled over the loss, why use one of the confidence in the last dim [:, :, 0]

# derived from cross_entropy=sum(log(p))
loss = -F.log_softmax(confidence, dim=2)[:, :, 0]
lufficc commented 3 years ago

confidence has a shape of (batch_size, num_priors, num_classes). Index 0 of the last dim is the prob of background, which is used to find difficult samples(i.e., is more confident to be background). This is called hard negative mining.

I hope this can solve your puzzle.

smartadpole commented 3 years ago

thankyou