且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Keras如何计算多类别分类问题的验证准确性和训练准确性?

更新时间:2022-11-28 21:00:00

您可以找到指标

You can find the metrics file and their implementation in the Keras github repo. In this case following metric applies:

def categorical_accuracy(y_true, y_pred):
    return K.cast(K.equal(K.argmax(y_true, axis=-1),
                          K.argmax(y_pred, axis=-1)),
                          K.floatx()) 

这通过检查预测类别是否与真实类别相同来计算单个(y_true,y_pred)对的准确性.这样做是为了比较y_pred向量中得分最高的类别的索引和y_true向量中实际类别的索引.返回0或1.

This calculates the accuracy of a single (y_true, y_pred) pair by checking if the predicted class is the same as the true class. It does this so comparing the index of the highest scoring class in y_pred vector and the index of the actual class in the y_true vector. It returns 0 or 1.

它使用此功能通过使用传统的精度公式(定义为

It uses this function to calculate the overall accuracy of the data set, by using the conventional accuracy formula, which is defined as

(amount of correct guesses)/(total amount of guesses)