SsisyphusTao / Object-Detection-Knowledge-Distillation

An Object Detection Knowledge Distillation framework powered by pytorch, now having SSD and yolov5.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bounded regression loss

PalkoNazar opened this issue · comments

https://github.com/SsisyphusTao/SSD-Knowledge-Distillation/blob/0597fbee635afcf0b8710ba3a9e40ab9f010aea5/nets/multibox_loss.py#L17-L23
F.mse_loss has reduction='mean' by default, but we should use reduction='sum' as for loss_l
https://github.com/SsisyphusTao/SSD-Knowledge-Distillation/blob/0597fbee635afcf0b8710ba3a9e40ab9f010aea5/nets/multibox_loss.py#L120
I think the next code corresponds to the formula from the article.

def bounded_regression_loss(Rs, Rt, gt, m, v=0.5):
    loss = torch.sum(F.mse_loss(Rs, gt, reduction='none'), 1)
    return torch.sum(loss * (loss + m > torch.sum(F.mse_loss(Rt, gt, reduction='none'), 1))) * v