Skip to content

Instantly share code, notes, and snippets.

@edgarriba
Created February 15, 2017 11:00
Show Gist options
  • Save edgarriba/c5f75318f31fe1a21619121b86fc9c30 to your computer and use it in GitHub Desktop.
Save edgarriba/c5f75318f31fe1a21619121b86fc9c30 to your computer and use it in GitHub Desktop.
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!')
@edgarriba
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment