Last active
April 20, 2019 15:29
-
-
Save solaris33/12dc63036219ca06ae5decf4258073be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import tensorflow as tf | |
i = tf.constant(1) | |
j = tf.constant(1) | |
k = tf.constant(1) | |
def cond(i, j, k): | |
return tf.less(i, 10) | |
def body(i, j, k): | |
add_op = tf.add(i, 1) | |
multiply_op = tf.multiply(j, i) | |
multiply_and_add_op = k * i + j | |
return [add_op, multiply_op, multiply_and_add_op] | |
result = tf.while_loop(cond, body, [i, j, k]) | |
with tf.Session() as sess: | |
loop_result = sess.run(result) | |
print(loop_result) | |
print(loop_result[0]) | |
print(loop_result[1]) | |
print(loop_result[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment