filter param with no grad (#579)

This commit is contained in:
Ir1dXD
2019-12-04 07:04:58 -05:00
committed by William Falcon
parent b5b77e44b1
commit d4571d1d6f
@@ -13,7 +13,7 @@ class TrainerTrainingTricksMixin(object):
def print_nan_gradients(self):
model = self.get_model()
for param in model.parameters():
if torch.isnan(param.grad.float()).any():
if (param.grad is not None) and torch.isnan(param.grad.float()).any():
logging.info(param, param.grad)
def configure_accumulated_gradients(self, accumulate_grad_batches):