[tf.data] Generalization of `tf.contrib.data.sliding_window_batch`.
Prior to this CL, the signature of the method was `sliding_window_batch(window_size, stride=1)`. This CL changes the signature to `sliding_window_batch(window_size, stride=None, window_shift=None, window_stride=1)`, where the `window_shift` argument acts as the original `stride` argument (determining the shift between consecutive windows), while the `window_stride` argument determines the stride of the input elements in the window.
For example, if `a = { [1], [2], [3], [4], [5], [6] }` is a dataset, then:
```
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]] }
```
PiperOrigin-RevId: 204770909
Loading
Please sign in to comment