This commit is contained in:
Glenn Jocher 2020-03-09 20:08:19 -07:00
parent 17a06dcf83
commit d55dbc1f29
1 changed files with 3 additions and 1 deletions

View File

@ -94,9 +94,11 @@ def create_modules(module_defs, img_size, arc):
bc = math.log(1 / (modules.nc - 0.99)) # cls bias: class probability is sigmoid(p) = 1/nc
j = l[yolo_index] if 'from' in mdef else -1
bias = module_list[j][0].bias.view(modules.na, -1) # 255 to 3x85
bias_ = module_list[j][0].bias # shape(255,)
bias = bias_[:modules.no * modules.na].view(modules.na, -1) # shape(3,85)
bias[:, 4] += bo - bias[:, 4].mean() # obj
bias[:, 5:] += bc - bias[:, 5:].mean() # cls, view with utils.print_model_biases(model)
module_list[j][0].bias = torch.nn.Parameter(bias_, requires_grad=bias_.requires_grad)
except:
print('WARNING: smart bias initialization failure.')