Keras set Top5 accuracy

 

import keras

def acc_top5(y_true, y_pred):
    return keras.metrics.top_k_categorical_accuracy(y_true, y_pred, k=5)
model.compile(loss=loss, optimizer=optimizer, metrics=['accuracy', acc_top5])

If you want to set other accuracy, modify the value of k in top_k_categorical_accuracy (y_true, y_pred, k = 5). Here I set the accuracy of top5

Published 141 original articles · Like 54 · Visits 150,000+

Guess you like

Origin blog.csdn.net/iamjingong/article/details/100586278