Pytorch tensor to numpy array

前端 未结 6 1297
名媛妹妹
名媛妹妹 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:07

    There are 4 dimensions of the tensor you want to convert.

    [:, ::-1, :, :] 
    

    : means that the first dimension should be copied as it is and converted, same goes for the third and fourth dimension.

    ::-1 means that for the second axes it reverses the the axes

提交回复
热议问题