【发布时间】:2017-01-20 09:07:17
【问题描述】:
问题
我尝试使用 Tensorflow 制作一个 softmax 分类器,并使用 tf.argmax() 进行预测。我发现y_ 之一总是高于0.5,我使用tf.round() 而不是tf.argmax()。
但是,这两种方法之间的准确率差距约为 20% - tf.round() 的准确率高于tf.argmax()。
我预计这两种方法的准确性应该完全相同,或者tf.round() 应该低于tf.argmax(),但事实并非如此。有谁知道为什么会这样?
Y 和 y_
Y=[[1,0,0],
[0,1,0],
[0,0,1], ......] : One-hot (target)
y_=[[0.92, 0.4, 0.4],
[0.2,0.6,0.2],
[0.2,0.4,0.2], ......] : output of softmax
正确的预测
correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
correct_prediction = tf.equal(tf.round(y), tf.round(y_))
准确度
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
【问题讨论】:
标签: python tensorflow prediction softmax