Skip to content

Commit

Permalink
leaf Variable inplace bug fix (ultralytics#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Dec 23, 2020
1 parent 25de2a5 commit 12fcb35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is
m = self.model[-1] # Detect() module
for mi, s in zip(m.m, m.stride): # from
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
b[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
b[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
b.data[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
b.data[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)

def _print_biases(self):
Expand Down

0 comments on commit 12fcb35

Please sign in to comment.