Calculate and print the mean of average absolute(gradients) Parameters: net (torch network) -- Torch network name (str) -- the name of the network
(net, name='network')
| 26 | |
| 27 | |
| 28 | def diagnose_network(net, name='network'): |
| 29 | """Calculate and print the mean of average absolute(gradients) |
| 30 | |
| 31 | Parameters: |
| 32 | net (torch network) -- Torch network |
| 33 | name (str) -- the name of the network |
| 34 | """ |
| 35 | mean = 0.0 |
| 36 | count = 0 |
| 37 | for param in net.parameters(): |
| 38 | if param.grad is not None: |
| 39 | mean += torch.mean(torch.abs(param.grad.data)) |
| 40 | count += 1 |
| 41 | if count > 0: |
| 42 | mean = mean / count |
| 43 | print(name) |
| 44 | print(mean) |
| 45 | |
| 46 | |
| 47 | def save_image(image_numpy, image_path, aspect_ratio=1.0): |
nothing calls this directly
no outgoing calls
no test coverage detected