TensorFlow报错run() got multiple values for argument 'feed_dict'

这个报错是因为sess.run(a,b,c)里要运行的多个变量没有用中括号括起来

举个错误的例子:下面报错是因为sess.run里的c和d没有用中括号

import tensorflow as tf

a = tf.placeholder(tf.float32, [1])
b = tf.placeholder(tf.float32, [1])
c = tf.multiply(a, b)
d = tf.add(a, b)

with tf.Session() as sess:
    prod, sum_ab = sess.run(c, d, feed_dict={a: [1.], b: [2.]})
    print(prod, sum_ab)

应该将后面那段程序改成:

import tensorflow as tf

a = tf.placeholder(tf.float32, [1])
b = tf.placeholder(tf.float32, [1])
c = tf.multiply(a, b)
d = tf.add(a, b)

with tf.Session() as sess:
    prod, sum_ab = sess.run([c, d], feed_dict={a: [1.], b: [2.]})
    print(prod, sum_ab)

 

你可能感兴趣的:(TensorFlow报错)