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