<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/core.py#L467-L495) |

Return a slice of an input tensor.

    tf.keras.ops.slice(
        inputs, start_indices, shape
    )

At a high level, this operation is an explicit replacement for array slicing
e.g. `inputs[start_indices: start_indices + shape]`.
Unlike slicing via brackets, this operation will accept tensor start
indices on all backends, which is useful when indices dynamically computed
via other tensor operations.

    inputs = np.zeros((5, 5))
    start_indices = np.array([3, 3])
    shape = np.array([2, 2])
    inputs = keras.ops.slice(inputs, start_indices, shape)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `inputs` | A tensor, the tensor to be updated. |
| `start_indices` | A list/tuple of shape `(inputs.ndim,)`, specifying the starting indices for updating. |
| `shape` | The full shape of the returned slice. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor, has the same shape and dtype as `inputs`. ||

<br />