Merge pull request #398 from PNRxA/dev

numpy to use CPU when using CUDA
This commit is contained in:
Eren Gölge 2020-04-25 12:01:04 +02:00 committed by GitHub
commit f7b1cad9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -157,7 +157,7 @@ def check_update(model, grad_clip, ignore_stopnet=False):
grad_norm = torch.nn.utils.clip_grad_norm_([param for name, param in model.named_parameters() if 'stopnet' not in name], grad_clip)
else:
grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), grad_clip)
if np.isinf(grad_norm):
if np.isinf(grad_norm.cpu()):
print(" | > Gradient is INF !!")
skip_flag = True
return grad_norm, skip_flag