import torch
import numpy as np
np_data = np.arange(6).reshape((2, 3))
torch_data = torch.from_numpy(np_data)
tensor2array = torch_data.numpy()
print(
'\nnumpy', np_data,
'\ntorch', torch_data,
'\ntensor2array', tensor2array,
)
numpy [[0 1 2]
[3 4 5]]
torch
0 1 2
3 4 5
[torch.LongTensor of size 2x3]
tensor2array [[0 1 2]
[3 4 5]]