提交 7eaf225d authored 作者: Glenn Jocher's avatar Glenn Jocher

zero-target training bug fix (#609)

上级 d0d3dd10
......@@ -496,7 +496,6 @@ 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.)
if model.nc > 1:
lcls *= h['cls'] * s
bs = tobj.shape[0] # batch size
......@@ -524,7 +523,7 @@ def build_targets(p, targets, model):
gain[2:6] = torch.tensor(p[i].shape)[[3, 2, 3, 2]] # xyxy gain
# Match targets to anchors
t, offsets = targets * gain, 0
t = targets * gain
if nt:
# Matches
r = t[:, :, 4:6] / anchors[:, None] # wh ratio
......@@ -540,6 +539,9 @@ def build_targets(p, targets, model):
j = torch.stack((torch.ones_like(j), j, k, l, m))
t = t.repeat((5, 1, 1))[j]
offsets = (torch.zeros_like(gxy)[None] + off[:, None])[j]
else:
t = targets[0]
offsets = 0
# Define
b, c = t[:, :2].long().T # image, class
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论