On this page
tf.data.experimental.group_by_reducer
A transformation that groups elements and performs a reduction.
tf.data.experimental.group_by_reducer(
    key_func, reducer
)
This transformation maps element of a dataset to a key using key_func and groups the elements by key. The reducer is used to process each group; its init_func is used to initialize state for each group when it is created, the reduce_func is used to update the state every time an element is mapped to the matching group, and the finalize_func is used to map the final state to an output value.
| Args | |
|---|---|
| key_func | A function mapping a nested structure of tensors (having shapes and types defined by self.output_shapesandself.output_types) to a scalartf.int64tensor. | 
| reducer | An instance of Reducer, which captures the reduction logic using theinit_func,reduce_func, andfinalize_funcfunctions. | 
| Returns | |
|---|---|
| A Datasettransformation function, which can be passed totf.data.Dataset.apply. | 
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
 https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/data/experimental/group_by_reducer