WindowDataset

public final class WindowDataset

Combines (nests of) input elements into a dataset of (nests of) windows.

A "window" is a finite dataset of flat elements of size `size` (or possibly fewer if there are not enough input elements to fill the window and `drop_remainder` evaluates to false).

The `shift` argument determines the number of input elements by which the window moves on each iteration. The first element in the `k`th window will be element

1 + (k-1) * shift
   
of the input dataset. In particular, the first element of the first window will always be the first element of the input dataset.

If the `stride` parameter is greater than 1, then each window will skip `(stride - 1)` input elements between each element that appears in the window. Output windows will still contain `size` elements regardless of the value of `stride`.

The `stride` argument determines the stride of the input elements, and the `shift` argument determines the shift of the window.

For example, letting `{...}` to represent a Dataset:

- `tf.data.Dataset.range(7).window(2)` produces `{ {0, 1}, {2, 3}, {4, 5}, {6} }` - `tf.data.Dataset.range(7).window(3, 2, 1, True)` produces `{ {0, 1, 2}, {2, 3, 4}, {4, 5, 6} }` - `tf.data.Dataset.range(7).window(3, 1, 2, True)` produces `{ {0, 2, 4}, {1, 3, 5}, {2, 4, 6} }`

Note that when the `window` transformation is applied to a dataset of nested elements, it produces a dataset of nested windows.

For example:

- `tf.data.Dataset.from_tensor_slices((range(4), range(4))).window(2)` produces `{({0, 1}, {0, 1}), ({2, 3}, {2, 3})}` - `tf.data.Dataset.from_tensor_slices({"a": range(4)}).window(2)` produces `{ {"a": {0, 1} }, {"a": {2, 3} } }`

Constants

String OP_NAME The name of this op, as known by TensorFlow core engine

Public Methods

Output < TType >
asOutput ()
Returns the symbolic handle of the tensor.
static WindowDataset
create ( Scope scope, Operand <?> inputDataset, Operand < TInt64 > size, Operand < TInt64 > shift, Operand < TInt64 > stride, Operand < TBool > dropRemainder, List<Class<? extends TType >> outputTypes, List< Shape > outputShapes)
Factory method to create a class wrapping a new WindowDataset operation.
Output <?>

Inherited Methods

Constants

public static final String OP_NAME

The name of this op, as known by TensorFlow core engine

Constant Value: "WindowDataset"

Public Methods

public Output < TType > asOutput ()

Returns the symbolic handle of the tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

public static WindowDataset create ( Scope scope, Operand <?> inputDataset, Operand < TInt64 > size, Operand < TInt64 > shift, Operand < TInt64 > stride, Operand < TBool > dropRemainder, List<Class<? extends TType >> outputTypes, List< Shape > outputShapes)

Factory method to create a class wrapping a new WindowDataset operation.

Parameters
scope current scope
size An integer scalar, representing the number of elements of the input dataset to combine into a window. Must be positive.
shift An integer scalar, representing the number of input elements by which the window moves in each iteration. Defaults to `size`. Must be positive.
stride An integer scalar, representing the stride of the input elements in the sliding window. Must be positive. The default value of 1 means "retain every input element".
dropRemainder A Boolean scalar, representing whether the last window should be dropped if its size is smaller than `window_size`.
Returns
  • a new instance of WindowDataset

public Output <?> handle ()