Pytorch tensor to numpy array

前端 未结 6 1296
名媛妹妹
名媛妹妹 2021-02-01 01:31

I have a pytorch Tensor of size torch.Size([4, 3, 966, 1296])

I want to convert it to numpy array using the following code:

<
6条回答
  •  既然无缘
    2021-02-01 02:08

    You can use this syntax if some grads are attached with your variables.

    y=torch.Tensor.cpu(x).detach().numpy()[:,:,:,-1]

提交回复
热议问题