Aggregating local models
The aggregation.py
code handles aggregating local models with a bunch of aggregation algorithms. In the code example, we only support FedAvg, as discussed in the following sections.
Importing the libraries for the aggregator
The aggregation.py
code imports the following:
import logging import time import numpy as np from typing import List from .state_manager import StateManager from fl_main.lib.util.helpers import generate_model_id from fl_main.lib.util.states import IDPrefix
The imported state manager’s role and functionalities are discussed in the Maintaining models for aggregation with the state manager section, and the helpers
and states
libraries are introduced in the Appendix, Exploring Internal Libraries.
After importing the necessary libraries, let’s define the aggregator class.
Defining and initializing the aggregator class
The following code for class Aggregator
defines the core process of the aggregator, which...