<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#L456-L488) |

Expands the dimension of last axis into sequences of `sequence_length`.

    tf.keras.ops.extract_sequences(
        x, sequence_length, sequence_stride
    )

Slides a window of size `sequence_length` over the last axis of the input
with a stride of `sequence_stride`, replacing the last axis with
`[num_sequences, sequence_length]` sequences.

If the dimension along the last axis is N, the number of sequences can be
computed by:

`num_sequences = 1 + (N - sequence_length) // sequence_stride`

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input tensor. |
| `sequence_length` | An integer representing the sequences length. |
| `sequence_stride` | An integer representing the sequences hop size. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor of sequences with shape \[..., num_sequences, sequence_length\]. ||

<br />

#### Example:

    x = keras.ops.convert_to_tensor([1, 2, 3, 4, 5, 6])
    extract_sequences(x, 3, 2)
    array([[1, 2, 3],
       [3, 4, 5]])