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

后端 未结 6 1809
孤城傲影
孤城傲影 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:37

    In later versions (tested with TensorFlow 1.14) there's a more numpy-like way to get the shape of a tensor. You can use tensor.shape to get the shape of the tensor.

    tensor_shape = tensor.shape
    print(tensor_shape)
    

提交回复
热议问题