Commit d1e7fe7e authored by Jiri Simsa's avatar Jiri Simsa Committed by TensorFlower Gardener
Browse files

[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
parent 0e14f115
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment