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

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

    for a 2-D tensor, you can get the number of rows and columns as int32 using the following code:

    rows, columns = map(lambda i: i.value, tensor.get_shape())
    

提交回复
热议问题