Abh*_*ngh 4 python evaluation machine-learning tensorflow
我正在使用 tf 指标来计算精度和召回率,但总是得到 0.0,但是当我自己计算时,我获得了很好的准确性,这是 tensorflow 的错误还是我做错了什么。
with tf.name_scope("pointwise_accuracy"):
correct_predictions = tf.equal(self.predictions, tf.argmax(self.input_y, 1))
self.classification_accuracy = tf.reduce_mean(tf.cast(correct_predictions, "float"), name="accuracy")
self.precision = tf.metrics.precision(self.input_y, self.logits, name="precison")[0]
Run Code Online (Sandbox Code Playgroud)
输出精度 - 0.0
tf.metrics.precision仅用于二元分类问题,它的参数必须是 all0或1因为,正如文档所说,它们将被转换为bool. 如果您确实在处理二元分类问题,但想使用 logits 作为参数,您可以查看tf.metrics.precision_at_thresholds,它允许您指定预测将被视为正确的阈值。
但是,由于您的手动计算使用tf.argmax,它看起来更像是一个多类分类问题,在这种情况下,您通常不会谈论精度/召回率,而只会谈论准确性,因此您可以将tf.metrics.accuracy、 和传递tf.argmax(self.input_y, 1)和self.predictions作为参数。
| 归档时间: |
|
| 查看次数: |
1466 次 |
| 最近记录: |