Created
February 15, 2017 11:00
-
-
Save edgarriba/c5f75318f31fe1a21619121b86fc9c30 to your computer and use it in GitHub Desktop.
check for NaN from: https://github.com/pytorch/pytorch/blob/master/torch/autograd/_functions/basic_ops.py#L177
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import numpy as np | |
import pickle | |
f = open('/home/eriba/software/pytorch/examples-edgarriba/triplet/nan_test.pkl', 'rb') | |
data = pickle.load(f) | |
a = torch.from_numpy(data['a']).cuda() | |
constant = data['constant'] | |
grad_output = torch.from_numpy(data['grad_output']).cuda() | |
res = grad_output.mul(constant).mul_(a.pow(constant - 1)) | |
if np.isnan(np.sum(res.cpu().numpy())): | |
print('NaNaNaNaNaNa') | |
else: | |
print('All is okay!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download file
nan_test.pkl
: https://drive.google.com/file/d/0B6YZ_Hvo2tLQdVBzcmJXYXNHblU/view?usp=sharing