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