How to get Tensorflow tensor dimensions (shape) as int values?

后端 未结 6 1796
孤城傲影
孤城傲影 2020-12-12 20:23

Suppose I have a Tensorflow tensor. How do I get the dimensions (shape) of the tensor as integer values? I know there are two methods, tensor.get_shape() and

6条回答
  •  無奈伤痛
    2020-12-12 20:35

    Another simple solution is to use map() as follows:

    tensor_shape = map(int, my_tensor.shape)
    

    This converts all the Dimension objects to int

提交回复
热议问题