This commit is contained in:
Glenn Jocher 2020-01-06 12:35:10 -08:00
parent 3b1caf9a43
commit 09ff72bc7b
1 changed files with 3 additions and 2 deletions

View File

@ -436,9 +436,10 @@ def compute_loss(p, targets, model): # predictions, targets, model
lcls *= h['cls']
if red == 'sum':
bs = tobj.shape[0] # batch size
lbox *= 3 / ng
lobj *= 3 / (6300 * bs) * 2 # 3 / np * 2
lcls *= 3 / ng / model.nc
if ng:
lcls *= 3 / ng / model.nc
lbox *= 3 / ng
loss = lbox + lobj + lcls
return loss, torch.cat((lbox, lobj, lcls, loss)).detach()