Summary

ref Why PyTorch?

  • NumPy-like arrays on GPU’s

  • Dynamic computational graphs

  • It’s Pythonic!

    Compuatiation graph is created dynamically as new statements are added to th code. e.g.:

Details

NumPy to PyTorch

Since NumPy and PyTorch are really similar, is there a method to change NumPy array to PyTorch array and vice versa? Yes!

a = np.ones(5)
#From NumPy to Torch
b = torch.from_numpy(a)
print('a:',a)
print('b:',b)