https://blog.csdn.net/qq_28660035/article/details/79062860
import numpy as np
import torch
x_tensor = torch.randn(2,3)#size(2,3)随机张量
y_numpy = np.random.randn(2,3)#size(2,3)随机矩阵
x_numpy = x_tensor.numpy()#张量转化numpy
#or
y_tensor = torch.fromnumpy(y_numpy)#numpy转化张量