Tensor转array 格式
>>> x = torch.rand(4)
>>> x
tensor([0.3661, 0.5859, 0.3220, 0.2511])
>>> c = x.numpy()
>>> c
array([0.36606663, 0.5859333 , 0.32197744, 0.25109816], dtype=float32)
>>>
Array 转 tensor格式
>>> import numpy as np
>>> x = np.ones(2)
>>> x
array([1., 1.])
>>> c = torch.from_numpy(x)
>>> c
tensor([1., 1.], dtype=torch.float64)
>>>