tff.analytics.data_processing.get_capped_elements
Stay organized with collections
Save and categorize content based on your preferences.
Gets the first max_user_contribution
elements from the input dataset.
tff.analytics.data_processing.get_capped_elements(
dataset: tf.data.Dataset,
max_user_contribution: int,
batch_size: int = 1,
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 caps the total
number of elements to return. Note either none of the elements in one batch is
added to the returned result, or all the elements are added. This means the
length of the returned list of elements could be less than
max_user_contribution
when dataset
is capped.
Args |
dataset
|
A tf.data.Dataset .
|
max_user_contribution
|
The maximum number of elements to return.
|
batch_size
|
The number of elements in each batch of dataset .
|
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 elements of the input dataset after being
capped. If the total number of elements is less than or equal to
max_user_contribution , returns all the elements in dataset .
|
Raises |
ValueError
|
-- If the shape of elements in dataset is not rank 1.
-- If max_user_contribution is less than 1.
-- If batch_size is less than 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.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-09-20 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-20 UTC."],[],[]]