# tf.keras.backend.in_top_k

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/backend/in_top_k) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/backend.py#L4700-L4714) |

Returns whether the `targets` are in the top `k` `predictions`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.keras.backend.in_top_k`](https://www.tensorflow.org/api_docs/python/tf/keras/backend/in_top_k)

<br />

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

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `predictions` | A tensor of shape `(batch_size, classes)` and type `float32`. |
| `targets` | A 1D tensor of length `batch_size` and type `int32` or `int64`. |
| `k` | An `int`, number of top elements to consider. |

<br />

<br />

<br />

<br />

| ## 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]`. ||

<br />