From f356b9387e56c379ee8ca58818972e90f97e45fc Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 16 Sep 2019 23:09:58 +0200 Subject: [PATCH] updates --- utils/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/utils.py b/utils/utils.py index 5a892150..c8458c8c 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -355,6 +355,11 @@ def compute_loss(p, targets, model): # predictions, targets, model lcls += BCEcls(ps[:, 5:], t) # BCE # lcls += CE(ps[:, 5:], tcls[i]) # CE + # Instance-class weighting (use with reduction='none') + # nt = t.sum(0) + 1 # number of targets per class + # lcls += (BCEcls(ps[:, 5:], t) / nt).mean() * nt.mean() # v1 + # lcls += (BCEcls(ps[:, 5:], t) / nt[tcls[i]].view(-1,1)).mean() * nt.mean() # v2 + # Append targets to text file # with open('targets.txt', 'a') as file: # [file.write('%11.5g ' * 4 % tuple(x) + '\n') for x in torch.cat((txy[i], twh[i]), 1)]