【发布时间】:2017-01-11 16:30:38
【问题描述】:
我有必要同时计算多个精度。
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))
这段代码与 TensorFlow 教程中的 mnist 示例相同,但没有:
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
我有两个占位符,因为我已经计算并存储了它们。
W = tf.placeholder(tf.float32, [784, 10])
b = tf.placeholder(tf.float32, [10])
我想用我现有的值填充网络,然后计算准确度,这对于我加载的每个网络都必须发生。
因此,如果我加载 20 个网络,我想并行计算每个网络的准确度。会话运行有没有办法用不同的输入执行相同的操作?
【问题讨论】:
-
您可以通过在不同的 Python 线程中运行多个
session.run并行调用