Gets the unique elements from the input dataset
.
@tf.function
tff.analytics.data_processing.get_unique_elements(
dataset: tf.data.Dataset, max_string_length: Optional[int] = None
)
The input dataset
must yield batched rank-1 tensors. This function reads
each coordinate of the tensor as an individual element and return unique
elements.
Args |
dataset
|
A tf.data.Dataset . Element type must be tf.string .
|
max_string_length
|
The maximum lenghth (in bytes) of strings in the dataset.
Strings longer than max_string_length will be truncated. Defaults to
None , which means there is no limit of the string length.
|
Returns |
A rank-1 Tensor containing the unique elements of the input dataset.
|
Raises |
ValueError
|
-- If the shape of elements in dataset is not rank 1.
-- If max_string_length is not None and is less than 1.
|
TypeError
|
If dataset.element_spec.dtype must be tf.string is not
tf.string .
|