tf.keras.backend.in_top_k

View source on GitHub

Returns whether the targets are in the top k predictions.

tf.keras.backend.in_top_k(
    predictions, targets, k
)

Arguments:

Returns:

A 1D tensor of length batch_size and type bool. output[i] is True if predictions[i, targets[i]] is within top-k values of predictions[i].