tff.simulation.compose_dataset_computation_with_iterative_process
Stay organized with collections
Save and categorize content based on your preferences.
Builds a new iterative process which constructs datasets on clients.
tff.simulation.compose_dataset_computation_with_iterative_process(
dataset_computation: tff.Computation
,
process: tff.templates.IterativeProcess
) -> tff.templates.IterativeProcess
Used in the notebooks
Given a tff.Computation
that returns a tf.data.Dataset
, and a
tff.templates.IterativeProcess
where exactly one of the arguments is a
dataset placed on clients of the same type as returned by the
tff.Computation
, this function will construct a new
tff.templates.IterativeProcess
whose next
function accepts a federated set
of values of the same type as the parameter of the dataset_computation
, maps
dataset_computation
over these values, and proceeds with the body of
process.next
.
For example, if the type signature of dataset_computation
is:
(T -> U*)
and the type signature of process.next
is:
(<S, {U*}@CLIENTS> -> <S, V>
then the returned tff.templates.IterativeProcess.next
type signature will
be:
(<S, {T}@CLIENTS> -> <S, V>)
This functionality is useful in several settings:
- We may want to push some dataset preprocessing to happen on the clients, as
opposed to preprocessing happening on the TFF simultation controller. This
may be necessary, e.g., in the case that we want to shuffle client
examples.
- We may want to construct the entire dataset on the clients, given a client
id. This may be useful in order to speed up distributed simulations, in
order to remove a linear cost incurred in constructing and serializign the
datasets on the controller.
Args |
dataset_computation
|
An instance of tff.Computation which accepts some
parameter and returns an element of tff.SequenceType .
|
process
|
An instance of tff.templates.IterativeProcess whose next function
accepts exactly one federated dataset, IE, element of type {B*}@CLIENTS ,
where B is equivalent to the return type of dataset_computation .
|
Raises |
TypeError
|
If the arguments are of the wrong types, or their TFF type
signatures are incompatible with the specification of this function.
|
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.simulation.compose_dataset_computation_with_iterative_process\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\nBuilds a new iterative process which constructs datasets on clients. \n\n tff.simulation.compose_dataset_computation_with_iterative_process(\n dataset_computation: ../../tff/Computation,\n process: ../../tff/templates/IterativeProcess\n ) -\u003e ../../tff/templates/IterativeProcess\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|-------------------------------------------------------------------------------------------------------------|\n| - [Working with tff's ClientData.](https://www.tensorflow.org/federated/tutorials/working_with_client_data) |\n\nGiven a [`tff.Computation`](../../tff/Computation) that returns a [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset), and a\n[`tff.templates.IterativeProcess`](../../tff/templates/IterativeProcess) where exactly one of the arguments is a\ndataset placed on clients of the same type as returned by the\n[`tff.Computation`](../../tff/Computation), this function will construct a new\n[`tff.templates.IterativeProcess`](../../tff/templates/IterativeProcess) whose `next` function accepts a federated set\nof values of the same type as the parameter of the `dataset_computation`, maps\n`dataset_computation` over these values, and proceeds with the body of\n`process.next`.\n\nFor example, if the type signature of `dataset_computation` is: \n\n (T -\u003e U*)\n\nand the type signature of `process.next` is: \n\n (\u003cS, {U*}@CLIENTS\u003e -\u003e \u003cS, V\u003e\n\nthen the returned [`tff.templates.IterativeProcess.next`](../../tff/templates/IterativeProcess#next) type signature will\nbe: \n\n (\u003cS, {T}@CLIENTS\u003e -\u003e \u003cS, V\u003e)\n\nThis functionality is useful in several settings:\n\n- We may want to push some dataset preprocessing to happen on the clients, as opposed to preprocessing happening on the TFF simultation controller. This may be necessary, e.g., in the case that we want to shuffle client examples.\n- We may want to *construct* the entire dataset on the clients, given a client id. This may be useful in order to speed up distributed simulations, in order to remove a linear cost incurred in constructing and serializign the datasets on the controller.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dataset_computation` | An instance of [`tff.Computation`](../../tff/Computation) which accepts some parameter and returns an element of [`tff.SequenceType`](../../tff/types/SequenceType). |\n| `process` | An instance of [`tff.templates.IterativeProcess`](../../tff/templates/IterativeProcess) whose next function accepts exactly one federated dataset, IE, element of type `{B*}@CLIENTS`, where `B` is equivalent to the return type of `dataset_computation`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A new [`tff.templates.IterativeProcess`](../../tff/templates/IterativeProcess) satisfying the specification above. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------------|\n| `TypeError` | If the arguments are of the wrong types, or their TFF type signatures are incompatible with the specification of this function. |\n\n\u003cbr /\u003e"]]