This commit is contained in:
Glenn Jocher 2019-09-16 23:09:58 +02:00
parent e5ab942c14
commit f356b9387e
1 changed files with 5 additions and 0 deletions

View File

@ -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)]