From 23d2bde01f08352834de810e1d731c0a2137e944 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 1 Aug 2020 11:42:41 -0700 Subject: [PATCH] leaf variable --single-cls training bug fix (#593) --- utils/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/utils.py b/utils/utils.py index 30a45b2..184e8dc 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -493,7 +493,8 @@ def compute_loss(p, targets, model): # predictions, targets, model s = 3 / np # output count scaling lbox *= h['giou'] * s lobj *= h['obj'] * s * (1.4 if np == 4 else 1.) - lcls *= h['cls'] * s + if model.nc > 1: + lcls *= h['cls'] * s bs = tobj.shape[0] # batch size loss = lbox + lobj + lcls