Python 精度始终为零张量流度量

Python 精度始终为零张量流度量,python,tensorflow,machine-learning,evaluation,Python,Tensorflow,Machine Learning,Evaluation,我使用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(corr

我使用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]
输出 精度-0.0

仅用于二进制分类问题,其参数必须全部为
0
1
,因为正如文档所说,它们将转换为
bool
。如果您确实在处理一个二进制分类问题,但希望使用logits作为参数,那么可以查看,它允许您指定一个阈值,在该阈值下,预测将被视为真


但是,由于您的手动计算使用了
tf.argmax
,因此它看起来更像是一个多类分类问题,在这种情况下,您通常不谈论精度/召回,而只谈论准确性,因此您可以查看并传递
tf.argmax(self.input_y,1)
self.predictions
作为参数。

谢谢,我正在研究一个多类问题。