apply PEP8

This commit is contained in:
Jiri BOROVEC
2019-08-06 22:45:27 +02:00
parent eacd93e2f0
commit c44966a8bf
16 changed files with 74 additions and 66 deletions
+2 -2
View File
@@ -4,6 +4,7 @@ Module to describe gradients
from torch import nn
class GradInformation(nn.Module):
def grad_norm(self, norm_type):
@@ -17,11 +18,10 @@ class GradInformation(nn.Module):
norm = param_norm ** (1 / norm_type)
results['grad_{}_norm_{}'.format(norm_type, i)] = round(norm.data.cpu().numpy().flatten()[0], 3)
except Exception as e:
except Exception:
# this param had no grad
pass
total_norm = total_norm ** (1. / norm_type)
results['grad_{}_norm_total'.format(norm_type)] = round(total_norm.data.cpu().numpy().flatten()[0], 3)
return results