【发布时间】:2017-04-08 23:09:36
【问题描述】:
我正在评估我在 tensorflow 中的神经网络模型的结果(识别 CIFAR10 图像)。 在每个时代之后,我都会像这样在测试集上打印精度(x 是图像,y 是真实标签):
predict = tf.equal(tf.argmax(layer_model, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(predict, "float"))
print("Accuracy: ", accuracy.eval({ x: test_images, y: test_labels)
但是,我正在尝试为每类图像分别获得准确度结果:
# test_labels look like: [0,1,0,...,0], [0,0,0,1,...,0], ...
labels_classes = np.argwhere(test_labels == 1)
chosen_class = np.argwhere(labels_classes[:,1] == j)
chosen_class = chosen_class.reshape(chosen.shape[0])
class_images = test_images[chosen]
class_labels = test_labels[chosen]
accuracy.eval({x: class_images, y: class_labels)
第二种方式的打印精度平均会降低 10% 左右的结果。谁能告诉我这里发生了什么?
【问题讨论】:
标签: tensorflow average conv-neural-network evaluation