tensor转成numpy b = a.numpy() import torch a = torch.arange(5) b = a.numpy() print(a) print(type(a)) print(b) print(type(b)) numpy转成tensor b = torch.tensor(a) import torch import numpy as np a = np.ones(5) b = torch.tensor(a) print(a) print(type(a)) print(b) print(type(b))