蓝灯123

导航

可以用 torch.fron_numpy 将 Numpy 数组转化为 PyTorch 张量。

1 import torch 2 from torch.autograd import Variable 3 import numpy as np 4 x = np.array([[1,2,3],[2,3,4]]) 5 xt = torch.from_numpy(x) 6 print(xt)

posted on 2022-01-20 15:25  蓝灯123  阅读(59)  评论(0编辑  收藏  举报