feed_dict参数的作用是替换图中的某个tensor的值。例如:
a = tf.add(2, 5) #a=7
b = tf.multiply(a, 3) #b=3*7=21
with tf.Session() as sess:
print(sess.run(b))
replace_dict = {a:15} #用15代替b算式中的a
print(sess.run(b, feed_dict = replace_dict))
---------------------
输出如下:
a = tf.add(2, 5) #a=7
b = tf.multiply(a, 3) #b=3*7=21
with tf.Session() as sess:
print(sess.run(b))
replace_dict = {a:15} #用15代替b算式中的a
print(sess.run(b, feed_dict = replace_dict))
---------------------
输出如下:
21 45
Comments
Post a Comment