In [1]:
import warnings
warnings.filterwarnings('ignore')

In [2]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [3]:
import torch

In [4]:
x = torch.Tensor(5, 3)

In [6]:
x.numpy()


Out[6]:
array([[  2.94598539e+30,   4.58070455e-41,   1.82007730e-37],
       [  0.00000000e+00,   8.37286548e+30,   4.58070455e-41],
       [  0.00000000e+00,   0.00000000e+00,  -7.34259929e-14],
       [ -6.76236203e-38,   1.45414723e+31,   4.58070455e-41],
       [  0.00000000e+00,   0.00000000e+00,  -2.66983223e+04]], dtype=float32)

In [7]:
import numpy as np
a = np.ones(5)
b = torch.from_numpy(a)

In [8]:
b


Out[8]:
 1
 1
 1
 1
 1
[torch.DoubleTensor of size 5]

In [ ]: