Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of TF functions with uninferrable shapes
def model_fn_random_shape():
random_dim_size = tf.random_uniform(
shape=[], minval=0, maxval=5, dtype=tf.int32)
# Return a vector with a random number of elements, all of them 42.0
return tf.fill([random_dim_size], 42.)
def run_random_shapes_model():
with tf.Session() as sess:
x = tf.placeholder(tf.float32, name='x')
result = xla.compile(model_fn_random_shape)[0]
print("result = " + str(sess.run(result)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment