PyTorch: How to get the shape of a Tensor as a list of int

后端 未结 3 1051
囚心锁ツ
囚心锁ツ 2021-02-01 13:51

In numpy, V.shape gives a tuple of ints of dimensions of V.

In tensorflow V.get_shape().as_list() gives a list of integers of the dimensions of

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 14:25

    Previous answers got you list of torch.Size Here is how to get list of ints

    listofints = [int(x) for x in tensor.shape]
    

提交回复
热议问题