This transformation passes a sliding window over this dataset. The window size
is window_size, the stride of the input elements is window_stride, and the
shift between consecutive windows is window_shift. If the remaining elements
cannot fill up the sliding window, this transformation will drop the final
smaller element. For example:
# NOTE: The following examples use `{ ... }` to represent the
# contents of a dataset.
a = { [1], [2], [3], [4], [5], [6] }
a.apply(sliding_window_batch(window_size=3)) ==
{ [[1], [2], [3]], [[2], [3], [4]], [[3], [4], [5]], [[4], [5], [6]] }
a.apply(sliding_window_batch(window_size=3, window_shift=2)) ==
{ [[1], [2], [3]], [[3], [4], [5]] }
a.apply(sliding_window_batch(window_size=3, window_stride=2)) ==
{ [[1], [3], [5]], [[2], [4], [6]] }
Args
window_size
A tf.int64 scalar tf.Tensor, representing the number of
elements in the sliding window. It must be positive.
stride
(Optional.) A tf.int64 scalar tf.Tensor, representing the
forward shift of the sliding window in each iteration. The default is 1.
It must be positive. Deprecated alias for window_shift.
window_shift
(Optional.) A tf.int64 scalar tf.Tensor, representing the
forward shift of the sliding window in each iteration. The default is 1.
It must be positive.
window_stride
(Optional.) A tf.int64 scalar tf.Tensor, representing the
stride of the input elements in the sliding window. The default is 1.
It must be positive.
[[["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 2020-10-01 UTC."],[],[]]