1 ndarray --> tensor torch.from_numpy(ndarray类型变量) b = torch.from_numpy(a) 2 tensor --> ndarray tensor类型变量.numpy() b = a.numpy() 感谢链接: https://zhuanlan.zhihu.com/p/65624441