转载:https://www.e-learn.cn/content/qita/722866
1、将numpy矩阵转换为Tensor张量
locs= torch.from_numpy(loc) #loc为numpy类型
2、将Tensor张量转化为numpy矩阵
locs1 = locs.numpy()
3、将numpy转换为Variable
locs2= Variable(torch.from_numpy(locs1))
4、将Variable张量转化为numpy
locs3 = locs2.data.numpy()