从Tensor到numpy
tensor = torch.Tensor([0,1]) # 如果参数不是一个list,而是一个int,将会返回该int长的内容未定义的Tensor
tensor_numpy = tensor.numpy()
从numpy到Tensor
array = np.random.rand(3)
torch.from_numpy(array)
从Tensor到numpy
tensor = torch.Tensor([0,1]) # 如果参数不是一个list,而是一个int,将会返回该int长的内容未定义的Tensor
tensor_numpy = tensor.numpy()
从numpy到Tensor
array = np.random.rand(3)
torch.from_numpy(array)