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.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.data.sliding_window_batch\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/data/python/ops/sliding.py#L66-L129) |\n\nA sliding window over a dataset. (deprecated) (deprecated arguments) \n\n tf.contrib.data.sliding_window_batch(\n window_size, stride=None, window_shift=None, window_stride=1\n )\n\n| **Warning:** SOME ARGUMENTS ARE DEPRECATED: `(stride)`. They will be removed in a future version. Instructions for updating: stride is deprecated, use window_shift instead\n| **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use `tf.data.Dataset.window(size=window_size, shift=window_shift, stride=window_stride).flat_map(lambda x: x.batch(window_size))` instead.\n\nThis transformation passes a sliding window over this dataset. The window size\nis `window_size`, the stride of the input elements is `window_stride`, and the\nshift between consecutive windows is `window_shift`. If the remaining elements\ncannot fill up the sliding window, this transformation will drop the final\nsmaller element. For example: \n\n # NOTE: The following examples use `{ ... }` to represent the\n # contents of a dataset.\n a = { [1], [2], [3], [4], [5], [6] }\n\n a.apply(sliding_window_batch(window_size=3)) ==\n { [[1], [2], [3]], [[2], [3], [4]], [[3], [4], [5]], [[4], [5], [6]] }\n\n a.apply(sliding_window_batch(window_size=3, window_shift=2)) ==\n { [[1], [2], [3]], [[3], [4], [5]] }\n\n a.apply(sliding_window_batch(window_size=3, window_stride=2)) ==\n { [[1], [3], [5]], [[2], [4], [6]] }\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `window_size` | A [`tf.int64`](../../../tf#int64) scalar [`tf.Tensor`](../../../tf/Tensor), representing the number of elements in the sliding window. It must be positive. |\n| `stride` | (Optional.) A [`tf.int64`](../../../tf#int64) scalar [`tf.Tensor`](../../../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`. |\n| `window_shift` | (Optional.) A [`tf.int64`](../../../tf#int64) scalar [`tf.Tensor`](../../../tf/Tensor), representing the forward shift of the sliding window in each iteration. The default is `1`. It must be positive. |\n| `window_stride` | (Optional.) A [`tf.int64`](../../../tf#int64) scalar [`tf.Tensor`](../../../tf/Tensor), representing the stride of the input elements in the sliding window. The default is `1`. It must be positive. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Dataset` transformation function, which can be passed to [`tf.data.Dataset.apply`](../../../tf/data/Dataset#apply). ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------|\n| `ValueError` | if invalid arguments are provided. |\n\n\u003cbr /\u003e"]]