def top_k_categorical_accuracy(y_true, y_pred, k=5):
return K.mean(K.in_top_k(y_pred, K.argmax(y_true, axis=-1), k), axis=-1)
def in_top1(x, y):
return top_k_categorical_accuracy(x, y, k=1)
def in_top5(x, y):
return top_k_categorical_accuracy(x, y, k=5)