tf.keras.ops.extract_sequences
Stay organized with collections
Save and categorize content based on your preferences.
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
Args |
x
|
Input tensor.
|
sequence_length
|
An integer representing the sequences length.
|
sequence_stride
|
An integer representing the sequences hop size.
|
Returns |
A tensor of sequences with shape [..., num_sequences, sequence_length].
|
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]])
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-06-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-07 UTC."],[],[]]