Created
November 7, 2018 01:20
-
-
Save jlebar/76e73ca2626231bd588cb03ec5f74fa3 to your computer and use it in GitHub Desktop.
Example of TF functions with uninferrable shapes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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