Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import tensorflow as tf
  2. sess = tf.InteractiveSession()
  3.  
  4. i = tf.constant(0, dtype=tf.int32)
  5. x = tf.constant(0, shape=[0], dtype=tf.int32)
  6.  
  7. i, x = tf.while_loop(lambda i, _: i < 10,
  8. lambda i, x: (i + 1, tf.concat_v2([x, tf.expand_dims(i, 0)], 0)),
  9. [i, x],
  10. shape_variants=[i.get_shape(), tf.TensorShape([None])])
  11.  
  12. print(x.eval())
  13.  
  14. [0 1 2 3 4 5 6 7 8 9]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement