tf.data.experimental.group_by_window

View source on GitHub

A transformation that groups windows of elements by key and reduces them.

tf.data.experimental.group_by_window(
    key_func, reduce_func, window_size=None, window_size_func=None
)

This transformation maps each consecutive element in a dataset to a key using key_func and groups the elements by key. It then applies reduce_func to at most window_size_func(key) elements matching the same key. All except the final window for each key will contain window_size_func(key) elements; the final window may be smaller.

You may provide either a constant window_size or a window size determined by the key through window_size_func.

Args:

Returns:

A Dataset transformation function, which can be passed to tf.data.Dataset.apply.

Raises: