import tensorflow as tf
#Fetch:在会话里可以执行多个op,并且得到运行的结果
input1 = tf.constant(3.0)
input2 = tf.constant(2.0)
input3 = tf.constant(5.0)
add = tf.add(input2,input3)#加法op
mul = tf.multiply(input1,add)#乘法op
with tf.Session() as sess:
result = sess.run([add,mul])#传入乘法op和加法op,Fetch就是多个op可以同时运行
print(result)
'''
#Feed
#创建占位符,可以在运行的时候再把值传入
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
output = tf.multiply(input1,input2)
with tf.Session() as sess:
#Feed的数据以字典的形式传入
print(sess.run(output,feed_dict={input1:[7.],input2:[2.]}))#数据以字典的形式传入,在运行的时候给前面两个placeholder赋值
'''