tff.learning.templates.compose_learning_process
Stay organized with collections
Save and categorize content based on your preferences.
Composes specialized measured processes into a learning process.
tff.learning.templates.compose_learning_process(
initial_model_weights_fn: tff.Computation
,
model_weights_distributor: tff.learning.templates.DistributionProcess
,
client_work: tff.learning.templates.ClientWorkProcess
,
model_update_aggregator: tff.templates.AggregationProcess
,
model_finalizer: tff.learning.templates.FinalizerProcess
) -> tff.learning.templates.LearningProcess
Used in the notebooks
Given 4 specialized measured processes (described below) that make a learning
process, and a computation that returns initial model weights to be used for
training, this method validates that the processes fit together, and returns a
LearningProcess
. Please see the tutorial at
https://www.tensorflow.org/federated/tutorials/composing_learning_algorithms
for more details on composing learning processes.
The main purpose of the 4 measured processes are:
model_weights_distributor
: Make global model weights at server available
as the starting point for learning work to be done at clients.
client_work
: Produce an update to the model received at clients.
model_update_aggregator
: Aggregates the model updates from clients to
the server.
model_finalizer
: Updates the global model weights using the aggregated
model update at server.
The next
computation of the created learning process is composed from the
next
computations of the 4 measured processes, in order as visualized below.
The type signatures of the processes must be such that this chaining is
possible. Each process also reports its own metrics.
┌─────────────────────────┐
│model_weights_distributor│
└△─┬─┬────────────────────┘
│ │┌▽──────────┐
│ ││client_work│
│ │└┬─────┬────┘
│┌▽─▽────┐│
││metrics││
│└△─△────┘│
│ │┌┴─────▽────────────────┐
│ ││model_update_aggregator│
│ │└┬──────────────────────┘
┌┴─┴─▽──────────┐
│model_finalizer│
└┬──────────────┘
┌▽─────┐
│result│
└──────┘
The get_hparams
computation of the created learning process produces a
nested ordered dictionary containing the result of client_work.get_hparams
and finalizer.get_hparams
. The set_hparams
computation operates similarly,
by delegating to client_work.set_hparams
and finalizer.set_hparams
to set
the hyperparameters in their associated states.
Raises |
ClientSequenceTypeError
|
If the first arg of the next method of the
resulting LearningProcess is not a structure of sequences placed at
tff.CLIENTS .
|
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.learning.templates.compose_learning_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\nComposes specialized measured processes into a learning process. \n\n tff.learning.templates.compose_learning_process(\n initial_model_weights_fn: ../../../tff/Computation,\n model_weights_distributor: ../../../tff/learning/templates/DistributionProcess,\n client_work: ../../../tff/learning/templates/ClientWorkProcess,\n model_update_aggregator: ../../../tff/templates/AggregationProcess,\n model_finalizer: ../../../tff/learning/templates/FinalizerProcess\n ) -\u003e ../../../tff/learning/templates/LearningProcess\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|-----------------------------------------------------------------------------------------------------------------|\n| - [Composing Learning Algorithms](https://www.tensorflow.org/federated/tutorials/composing_learning_algorithms) |\n\nGiven 4 specialized measured processes (described below) that make a learning\nprocess, and a computation that returns initial model weights to be used for\ntraining, this method validates that the processes fit together, and returns a\n`LearningProcess`. Please see the tutorial at\n\u003chttps://www.tensorflow.org/federated/tutorials/composing_learning_algorithms\u003e\nfor more details on composing learning processes.\n\nThe main purpose of the 4 measured processes are:\n\n- `model_weights_distributor`: Make global model weights at server available as the starting point for learning work to be done at clients.\n- `client_work`: Produce an update to the model received at clients.\n- `model_update_aggregator`: Aggregates the model updates from clients to the server.\n- `model_finalizer`: Updates the global model weights using the aggregated model update at server.\n\nThe `next` computation of the created learning process is composed from the\n`next` computations of the 4 measured processes, in order as visualized below.\nThe type signatures of the processes must be such that this chaining is\npossible. Each process also reports its own metrics. \n\n ┌─────────────────────────┐\n │model_weights_distributor│\n └△─┬─┬────────────────────┘\n │ │┌▽──────────┐\n │ ││client_work│\n │ │└┬─────┬────┘\n │┌▽─▽────┐│\n ││metrics││\n │└△─△────┘│\n │ │┌┴─────▽────────────────┐\n │ ││model_update_aggregator│\n │ │└┬──────────────────────┘\n ┌┴─┴─▽──────────┐\n │model_finalizer│\n └┬──────────────┘\n ┌▽─────┐\n │result│\n └──────┘\n\nThe `get_hparams` computation of the created learning process produces a\nnested ordered dictionary containing the result of `client_work.get_hparams`\nand `finalizer.get_hparams`. The `set_hparams` computation operates similarly,\nby delegating to `client_work.set_hparams` and `finalizer.set_hparams` to set\nthe hyperparameters in their associated states.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------------|--------------------------------------------------------------------------------------------------------|\n| `initial_model_weights_fn` | A [`tff.Computation`](../../../tff/Computation) that returns (unplaced) initial model weights. |\n| `model_weights_distributor` | A [`tff.learning.templates.DistributionProcess`](../../../tff/learning/templates/DistributionProcess). |\n| `client_work` | A [`tff.learning.templates.ClientWorkProcess`](../../../tff/learning/templates/ClientWorkProcess). |\n| `model_update_aggregator` | A [`tff.templates.AggregationProcess`](../../../tff/templates/AggregationProcess). |\n| `model_finalizer` | A [`tff.learning.templates.FinalizerProcess`](../../../tff/learning/templates/FinalizerProcess). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A [`tff.learning.templates.LearningProcess`](../../../tff/learning/templates/LearningProcess). ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ClientSequenceTypeError` | If the first arg of the `next` method of the resulting `LearningProcess` is not a structure of sequences placed at [`tff.CLIENTS`](../../../tff#CLIENTS). |\n\n\u003cbr /\u003e"]]