xain_fl.fl.coordinator package¶
Contains coordinator logic which runs the central server in federated learning. It consists of the following modules:
aggregate
controller
Submodules¶
xain_fl.fl.coordinator.aggregate module¶
Provides an abstract base class Aggregator and multiple sub-classes
-
class
xain_fl.fl.coordinator.aggregate.
Aggregator
¶ Bases:
abc.ABC
Abstract base class for model weights aggregation strategies.
-
abstract
aggregate
(multiple_model_weights, aggregation_data)¶ Aggregate the weights of multiple models.
- Parameters
multiple_model_weights (List[ndarray]) – The weights of multiple models.
aggregation_data (List[int]) – Meta data for model aggregation.
- Returns
The aggregated model weights.
- Return type
ndarray
-
abstract
-
class
xain_fl.fl.coordinator.aggregate.
IdentityAggregator
¶ Bases:
xain_fl.fl.coordinator.aggregate.Aggregator
Identity aggregation.
-
aggregate
(multiple_model_weights, aggregation_data)¶ Identity aggregation only for one set of model weights.
- Parameters
multiple_model_weights (List[ndarray]) – The weights of multiple models. Must have only one set of weights.
aggregation_data (List[int]) – Meta data for model aggregation. Not used here.
- Returns
The identical model weights.
- Return type
ndarray
- Raises
ValueError – If more than one set of model weights is provided.
-
-
class
xain_fl.fl.coordinator.aggregate.
ModelSumAggregator
¶ Bases:
xain_fl.fl.coordinator.aggregate.Aggregator
Summation of models aggregation.
-
aggregate
(multiple_model_weights, aggregation_data)¶ Aggregate the weights of multiple models by summation.
- Parameters
multiple_model_weights (List[ndarray]) – The weights of multiple models.
aggregation_data (List[int]) – Meta data for model aggregation. Not used here.
- Returns
The aggregated model weights.
- Return type
ndarray
-
-
class
xain_fl.fl.coordinator.aggregate.
WeightedAverageAggregator
¶ Bases:
xain_fl.fl.coordinator.aggregate.Aggregator
Weighted average aggregation.
-
aggregate
(multiple_model_weights, aggregation_data)¶ Aggregate the weights of multiple models by weighted averages.
Proposed by McMahan et al in: https://arxiv.org/abs/1602.05629
- Parameters
multiple_model_weights (List[ndarray]) – The weights of multiple models.
aggregation_data (List[int]) – Meta data for model aggregation. Here it is expected to be the number of train samples per set of model weights. If all numbers are zero, e.g. in a 0th round for weight initialization, then all model weights are weighted equally.
- Returns
The aggregated model weights.
- Return type
ndarray
-
xain_fl.fl.coordinator.controller module¶
Provides an abstract base class Controller and the RandomController currently used by the Coordinator.
-
class
xain_fl.fl.coordinator.controller.
Controller
(fraction_of_participants=1.0)¶ Bases:
abc.ABC
Abstract base class which provides an interface to the coordinator that enables different selection strategies.
-
fraction_of_participants
¶ The fraction of total participant IDs to be selected. Defaults to 1.0, meaning that all participant IDs will be selected. It must be in the (0.0, 1.0] interval.
- Type
float
, optional
-
get_num_ids_to_select
(len_participant_ids)¶ Calculates how many participant IDs need to be selected.
-
-
class
xain_fl.fl.coordinator.controller.
IdController
(fraction_of_participants=1.0)¶ Bases:
xain_fl.fl.coordinator.controller.Controller
[summary
… todo: Advance docstrings (https://xainag.atlassian.net/browse/XP-425)
-
class
xain_fl.fl.coordinator.controller.
RandomController
(fraction_of_participants=1.0)¶ Bases:
xain_fl.fl.coordinator.controller.Controller
[summary]
- Parameters
Controller ([type]) – [description]
-
select_ids
(participant_ids)¶ Randomly samples self.num_ids_to_select from the population of participants_ids, without replacement.