tff.analytics.data_processing.get_unique_elements
Stay organized with collections
Save and categorize content based on your preferences.
Gets the unique elements from the input dataset
.
@tf.function
tff.analytics.data_processing.get_unique_elements(
dataset: tf.data.Dataset, string_max_bytes: 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 .
|
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.
|
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 string_max_bytes is not None and is less than 1.
|
TypeError
|
If dataset.element_spec.dtype must be tf.string is not
tf.string .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.analytics.data_processing.get_unique_elements\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nGets the unique elements from the input `dataset`. \n\n @tf.function\n tff.analytics.data_processing.get_unique_elements(\n dataset: tf.data.Dataset, string_max_bytes: Optional[int] = None\n )\n\nThe input `dataset` must yield batched rank-1 tensors. This function reads\neach coordinate of the tensor as an individual element and return unique\nelements.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dataset` | A [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset). Element type must be [`tf.string`](https://www.tensorflow.org/api_docs/python/tf#string). |\n| `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. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A rank-1 Tensor containing the unique elements of the input dataset. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | -- If the shape of elements in `dataset` is not rank 1. -- If `string_max_bytes` is not `None` and is less than 1. |\n| `TypeError` | If `dataset.element_spec.dtype` must be [`tf.string`](https://www.tensorflow.org/api_docs/python/tf#string) is not [`tf.string`](https://www.tensorflow.org/api_docs/python/tf#string). |\n\n\u003cbr /\u003e"]]