This commit is contained in:
Glenn Jocher 2019-08-24 12:52:52 +02:00
parent b88c4568ba
commit 852487654f
1 changed files with 6 additions and 3 deletions

View File

@ -562,14 +562,17 @@ def print_model_biases(model):
'classification: %.2f+/-%.2f' % (b[:, 5:].mean(), b[:, 5:].std()))
def strip_optimizer(f='weights/best.pt'):
def strip_optimizer(f='weights/best.pt'): # from utils.utils import *; strip_optimizer()
# Strip optimizer from *.pt files for lighter files (reduced by 2/3 size)
x = torch.load(f)
x['optimizer'] = None
# x['training_results'] = None
# x['epoch'] = -1
# for p in x['model']:
# p.requires_grad = True
# for p in x['model'].values():
# try:
# p.requires_grad = True
# except:
# pass
torch.save(x, f)