1,numpy类型数据转换为tensor
torch_data = torch.from_numpy(np_data)
2,tensor转换为numpy类型数据
tensor2array = torch_data.numpy()
2, cudatensor 转numpy类型数据
cudatensor2array = torch_data.cpu().numpy()
1,numpy类型数据转换为tensor
torch_data = torch.from_numpy(np_data)
2,tensor转换为numpy类型数据
tensor2array = torch_data.numpy()
2, cudatensor 转numpy类型数据
cudatensor2array = torch_data.cpu().numpy()