【发布时间】:2020-11-21 17:43:33
【问题描述】:
下面的函数是用来计算逻辑回归的准确率的,但是在这个函数中使用reduce_mean函数有什么意义呢?
代码是:
import tensorflow as tf
def accuracy(y_pred, y_true):
# Predicted class is the index of the highest score in prediction vector (i.e. argmax).
correct_prediction = tf.equal(tf.argmax(y_pred, 1), tf.cast(y_true, tf.int64))
return tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
【问题讨论】:
标签: python tensorflow machine-learning keras logistic-regression