This commit is contained in:
Glenn Jocher 2018-11-23 15:32:41 +01:00
parent 887ab29c64
commit 6e825acb72
1 changed files with 3 additions and 3 deletions

View File

@ -22,12 +22,12 @@ def load_classes(path):
def model_info(model): # Plots a line-by-line description of a PyTorch model def model_info(model): # Plots a line-by-line description of a PyTorch model
n_p = sum(x.numel() for x in model.parameters()) # number parameters n_p = sum(x.numel() for x in model.parameters()) # number parameters
n_g = sum(x.numel() for x in model.parameters() if x.requires_grad) # number gradients n_g = sum(x.numel() for x in model.parameters() if x.requires_grad) # number gradients
print('\n%4s %70s %9s %12s %20s %12s %12s' % ('', 'name', 'gradient', 'parameters', 'shape', 'mu', 'sigma')) print('\n%5s %50s %9s %12s %20s %12s %12s' % ('layer', 'name', 'gradient', 'parameters', 'shape', 'mu', 'sigma'))
for i, (name, p) in enumerate(model.named_parameters()): for i, (name, p) in enumerate(model.named_parameters()):
name = name.replace('module_list.', '') name = name.replace('module_list.', '')
print('%4g %70s %9s %12g %20s %12g %12g' % ( print('%5g %50s %9s %12g %20s %12g %12g' % (
i, name, p.requires_grad, p.numel(), list(p.shape), p.mean(), p.std())) i, name, p.requires_grad, p.numel(), list(p.shape), p.mean(), p.std()))
print('\nModel Summary: %g layers, %g parameters, %g gradients\n' % (i + 1, n_p, n_g)) print('Model Summary: %g layers, %g parameters, %g gradients\n' % (i + 1, n_p, n_g))
def class_weights(): # frequency of each class in coco train2014 def class_weights(): # frequency of each class in coco train2014