B站:
http://www.bilibili.com/video/av20542427?share_medium=android&share_source=copy_link&bbid=8099B994-2CEF-4DB4-A914-9DC322B1E3A531040infoc&ts=1532354206207
#Fetch 同时执行多个op,得到运行结果
import tensorflow as tf
input1 = tf.constant(3.0)
input2 = tf.constant(2.0)
input3 = tf.constant(5.0)
add = tf.add(input2,input3)
mul = tf.multiply(input1,add)
with tf.Session() as sess:
print(sess.run([mul,add]))
"""
result:
[21.0, 7.0]
"""
#Feed
#创建32位浮点型占位符
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:[8.],input2:[2.]}))
"""
result:
[16.]
"""