<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/math.py#L293-L318) |

Checks if the targets are in the top-k predictions.

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

<br />

<br />

<br />

| ## Args ||
|---|---|
| `targets` | A tensor of true labels. |
| `predictions` | A tensor of predicted labels. |
| `k` | An integer representing the number of predictions to consider. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A boolean tensor of the same shape as `targets`, where each element indicates whether the corresponding target is in the top-k predictions. ||

<br />

#### Example:

    targets = keras.ops.convert_to_tensor([2, 5, 3])
    predictions = keras.ops.convert_to_tensor(
    [[0.1, 0.4, 0.6, 0.9, 0.5],
     [0.1, 0.7, 0.9, 0.8, 0.3],
     [0.1, 0.6, 0.9, 0.9, 0.5]])
    in_top_k(targets, predictions, k=3)
    array([ True False  True], shape=(3,), dtype=bool)