<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/numpy.py#L2877-L2897) |

Returns the indices of the bins to which each value in `x` belongs.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.digitize`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/digitize)

<br />

    tf.keras.ops.digitize(
        x, bins
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input array to be binned. |
| `bins` | Array of bins. It has to be one-dimensional and monotonically increasing. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Output array of indices, of same shape as `x`. ||

<br />

#### Example:

    x = np.array([0.0, 1.0, 3.0, 1.6])
    bins = np.array([0.0, 3.0, 4.5, 7.0])
    keras.ops.digitize(x, bins)
    array([1, 1, 2, 1])