Skip to content

Instantly share code, notes, and snippets.

@c0nn3r
Created August 10, 2018 23:02
Show Gist options
  • Save c0nn3r/f51845c1434beaa21467f435f0221719 to your computer and use it in GitHub Desktop.
Save c0nn3r/f51845c1434beaa21467f435f0221719 to your computer and use it in GitHub Desktop.
def shape_list(x):
"""
deal with dynamic shape in tensorflow cleanly
"""
ps = x.get_shape().as_list()
ts = tf.shape(x)
return [ts[i] if ps[i] is None else ps[i] for i in range(len(ps))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment