Basic Tensorflow example

Basic Tensorflow example

import tensorflow as tf

a = tf.constant(20)
b = tf.Variable(10)

result1 = tf.cond(a > b, lambda: a, lambda: b)
result2 = tf.cond(a < b, lambda: a, lambda: b)

# Initialize all the variables (including parameters) randomly.
init_op = tf.initialize_all_variables()

sess = tf.InteractiveSession()
# Run the init_op, evaluate the model outputs and print the results:
sess.run(init_op)

print(sess.run(a))
print(sess.run(b))
print("max value is: %d" % sess.run(result1))
print("min value is: %d" % sess.run(result2))

posted on 2017-11-21 11:20  yusisc  阅读(14)  评论(0编辑  收藏  举报

导航