tf.shape()与tensor.get_shape()

两种方法都可以获得变量的shape

tf.shape(x)   其中x可以是tensor, 也可不是tensor,返回是一个tensor.

shape=tf.placeholder(tf.float32, shape=[None, 227, 227, 3]]

 我们经常会这样来feed 数据,如果在运行的时候想知道None到底是多少,这时候只能通过tf.shape(x)[0]这种方式来获得

tensor.get_shape()

只有tensor 有这个方法, 返回的是一个tuple

猜你喜欢

转载自blog.csdn.net/gqixf/article/details/83108876