From 1d43b2a55aabf5afca1c6392fcacff061d0be00e Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 8 Mar 2020 16:13:56 -0700 Subject: [PATCH] updates --- utils/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/utils.py b/utils/utils.py index efb56891..9522ad4d 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -405,8 +405,15 @@ def compute_loss(p, targets, model): # predictions, targets, model tobj[b, a, gj, gi] = (1.0 - model.gr) + model.gr * giou.detach().clamp(0).type(tobj.dtype) # giou ratio if 'default' in arc and model.nc > 1: # cls loss (only if multiple classes) - t = torch.zeros_like(ps[:, 5:]) # targets - t[range(nb), tcls[i]] = 1.0 + smooth = False # class label smoothing https://arxiv.org/pdf/1902.04103.pdf eqn 3 + if smooth: + e = 0.1 #  class label smoothing epsilon + cp, cn = 1.0 - e, e / (model.nc - 0.99) # class positive and negative labels + else: + cp, cn = 1.0, 0.0 + + t = torch.zeros_like(ps[:, 5:]) + cn # targets + t[range(nb), tcls[i]] = cp lcls += BCEcls(ps[:, 5:], t) # BCE # lcls += CE(ps[:, 5:], tcls[i]) # CE