(x)
return ret
Return list of dims, statically where possible.
Return list of dims, statically where possible.
Return list of dims statically where possible .
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 enumerate(static):
    dim = static[i]
    if dim is None:
      dim = shape[i]
    ret.append(dim)
  return ret
def shape_list ( x ) : 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 enumerate ( static ) : dim = static [ i ] if dim is None : dim = shape [ i ] ret . append ( dim ) return ret