Gets top unique elements from the input dataset
.
@tf.function
tff.analytics.data_processing.get_top_elements_with_counts( dataset: tf.data.Dataset, max_user_contribution: int, string_max_bytes: Optional[int] = None ) -> tuple[tf.Tensor, tf.Tensor]
This method returns a tuple of elements
and counts
, where elements
are
the most common unique elements in the dataset, and counts is the number of
times each one appears. The input dataset
must yield batched rank-1 tensors.
This function reads each coordinate of the tensor as an individual element and
caps the total number of elements to return. Note that the returned set of top
elements will not necessarily be sorted.
Args | |
---|---|
dataset
|
A tf.data.Dataset to extract top elements from. Element type must
be tf.string .
|
max_user_contribution
|
The maximum number of elements to keep. |
string_max_bytes
|
The maximum length (in bytes) of strings in the dataset.
Strings longer than string_max_bytes will be truncated. Defaults to
None , which means there is no limit of the string length.
|