Guest User

Untitled

a guest
Jan 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import tensorflow as tf
  2.  
  3. result = tf.constant([0])
  4. i = tf.constant(0)
  5. c_1 = lambda i,result: tf.less(i, 10)
  6. def b_1(i,result):
  7.  
  8. j = tf.constant(0)
  9. c_2 = lambda i,j,res: tf.less(j, 10)
  10. result += 1
  11. def b_2(i, j,res):
  12. res += 1
  13.  
  14.  
  15. return i, tf.add(j, 1), res
  16. loop_2 = tf.while_loop(c_2, b_2, [i,j,result])
  17.  
  18.  
  19. return tf.add(i, 1), result
  20. loop_1 = tf.while_loop(c_1, b_1, [i,result])
  21.  
  22. with tf.Session() as sess:
  23. print(sess.run(loop_1))
Add Comment
Please, Sign In to add comment