fl4health.strategies.aggregate_utils module¶
- aggregate_losses(results, weighted=True)[source]¶
Aggregate evaluation results obtained from multiple clients.
- Parameters:
results (list[tuple[int, float]]) – A list of sample counts and loss values (in that order). The sample counts from each client (training or validation samples where appropriate) are used if weighted averaging is requested.
weighted (bool, optional) – Whether or not the aggregation is a weighted average (by the sample counts provided in the tuple) or a uniform average. Defaults to True.
- Returns:
the weighted or unweighted average of the loss values in the results list.
- Return type:
- aggregate_results(results, weighted=True)[source]¶
Compute weighted or unweighted average.
- Parameters:
results (list[tuple[NDArrays, int]]) – This is a set of NDArrays (list of numpy arrays) and the number of relevant samples from each client (training or validation samples where appropriate). These are to be aggregated together in a weighted or unweighted average. The NDArrays most often represent model states.
weighted (bool, optional) – Whether or not the aggregation is a weighted average (by the sample counts provided in the tuple) or a uniform average. Defaults to True.
- Returns:
Aggregated numpy arrays by the desired averaging.
- Return type:
NDArrays