Fetch与Feed
作者:互联网
Fetch是获取计算图中的数据的操作
# input1 = tf.constant(1.0)
# input2 = tf.constant(2.0)
# input3 = tf.constant(3.0)
#
# add = tf.add(input1, input3)
#
# mul = tf.multiply(input2, add)
#
# with tf.Session() as sess:
# mul_res = sess.run(mul)
# add_res = sess.run(add)
Feed是赋值操作,是将数据赋值到占位符操作
num1 = tf.placeholder(tf.float32)
num2 = tf.placeholder(tf.float32)
output = tf.multiply(num1, num2)
with tf.Session() as sess:
res = sess.run(output, feed_dict={num1: [0.2], num2: [0.8]})
print(type(res))
标签:Feed,sess,constant,num1,res,add,tf,Fetch 来源: https://blog.csdn.net/qq_45616304/article/details/119302288