def shape_list(x):
"""Return list of dims, statically where possible."""
x = tf.convert_to_tensor(x)
# If unknown rank, return dynamic shape
if x.get_shape().dims is None:
return tf.shape(x)
static = x.get_shape().as_list()
shape = tf.shape(x)
ret = []
for i in xrange(len(static)):
dim = static[i]
if dim is None:
dim = shape[i]
ret.append(dim)
return ret
评论列表
文章目录