This commit is contained in:
Glenn Jocher 2019-08-22 16:39:55 +02:00
parent 11aac8930b
commit 858fc67954
1 changed files with 9 additions and 0 deletions

View File

@ -552,6 +552,15 @@ def get_yolo_layers(model):
return [i for i, x in enumerate(bool_vec) if x] # [82, 94, 106] for yolov3 return [i for i, x in enumerate(bool_vec) if x] # [82, 94, 106] for yolov3
def print_model_biases(model):
# prints the bias neurons preceding each yolo layer
for l in model.yolo_layers: # print pretrained biases
b = model.module_list[l - 1][0].bias.view(3, -1) # bias 3x85
print('regression: %.2f+/-%.2f, ' % (b[:, :4].mean(), b[:, :4].std()),
'objectness: %.2f+/-%.2f, ' % (b[:, 4].mean(), b[:, 4].std()),
'classification: %.2f+/-%.2f' % (b[:, 5:].mean(), b[:, 5:].std()))
def strip_optimizer_from_checkpoint(filename='weights/best.pt'): def strip_optimizer_from_checkpoint(filename='weights/best.pt'):
# Strip optimizer from *.pt files for lighter files (reduced by 2/3 size) # Strip optimizer from *.pt files for lighter files (reduced by 2/3 size)
a = torch.load(filename, map_location='cpu') a = torch.load(filename, map_location='cpu')