View source on GitHub |
Runs a federated training_process
.
tff.simulation.run_training_process(
training_process: tff.templates.IterativeProcess
,
training_selection_fn: Callable[[int], Any],
total_rounds: int,
evaluation_fn: Optional[Callable[[Any, Any], MetricsType]] = None,
evaluation_selection_fn: Optional[Callable[[int], Any]] = None,
rounds_per_evaluation: int = 1,
program_state_manager: Optional[tff.program.ProgramStateManager
] = None,
rounds_per_saving_program_state: int = 1,
metrics_managers: Optional[Iterable[release_manager_lib.ReleaseManager]] = None
)
The following tff.Computation
types signaures are required:
training_process.initialize
:( -> state)
.training_process.next
:<state, client_data> -> <state, metrics>
evaulation_fn
:<state, client_data> -> metrics
This function performs up to total_rounds
updates to the state
of the
given training_process
. At each training round, this update occurs by
invoking training_process.next
with state
and the output of
training_selection_fn
. Depending on rounds_per_evaluation
and
rounds_per_saving_program_state
, each training round may be followed by an
invocation of the evaluation_fn
and by saving the program state.
In addition to the training metrics and evaluation metrics, this function adds the following performance metrics (key and descriptions):
- tff.simulation.ROUND_NUMBER_KEY: The round number.
- tff.simulation.TRAINING_TIME_KEY: The amount of time (in seconds) it takes to run one round of training.
- tff.simulation.EVALUATION_TIME_KEY: The amount of time (in seconds) it takes to run one round of evaluation.
Args | |
---|---|
training_process
|
A tff.templates.IterativeProcess to run for training.
|
training_selection_fn
|
A Callable accepting an integer round number, and
returning a list of client data to use for trainig in that round.
|
total_rounds
|
The number of training rounds to run. |
evaluation_fn
|
An optional callable accepting the state of
training_process and the output of evaluation_selection_fn , and
returning a mutable mapping with string-valued keys.
|
evaluation_selection_fn
|
A optional Callable accepting an integer round
number, and returning a list of client data to use for evaluation in that
round.
|
rounds_per_evaluation
|
The number of training rounds to run between each
invocation of evaluation_fn .
|
program_state_manager
|
An optional tff.program.ProgramStateManager to use
to save program state for fault tolerance.
|
rounds_per_saving_program_state
|
The number of training rounds to run between saving program state. |
metrics_managers
|
An optional list of tff.program.ReleaseManagers s to use
to save metrics.
|
Returns | |
---|---|
The state of the training process after training.
|