golf_federated.server.process.strategy.aggregation package¶
Submodules¶
golf_federated.server.process.strategy.aggregation.asynchronous module¶
-
class
golf_federated.server.process.strategy.aggregation.asynchronous.FedAsync(alpha: float = 0.5, beta: float = 0.0, staleness: str = 'Polynomial', min_to_start: int = 2)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedAsynchronous FL with FedAsync, inheriting from BaseFed class. From: “Asynchronous Federated Optimization”
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
-
class
golf_federated.server.process.strategy.aggregation.asynchronous.FedFD(min_to_start: int = 2)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedAsynchronous FL with FedFD, inheriting from BaseFed class.
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
-
class
golf_federated.server.process.strategy.aggregation.asynchronous.SLMFed_asyn(target_acc: float, func: str = 'other', min_to_start: int = 2)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedAsynchronous FL with SLMFed, inheriting from BaseFed class.
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
golf_federated.server.process.strategy.aggregation.base module¶
-
class
golf_federated.server.process.strategy.aggregation.base.BaseFed(name: str, synchronous: bool, min_to_start: int)[source]¶ Bases:
objectAggregation strategy base class.
-
abstract
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
abstract
golf_federated.server.process.strategy.aggregation.function module¶
-
golf_federated.server.process.strategy.aggregation.function.Cedarsyn(local_model: List, detect: bool, current_model: object, num_layer: int, layer_weight: List, stimulus_x: None._VariableFunctionsClass.tensor, require_judge_layer: List, upgrade_bool_list: pandas.core.frame.DataFrame) → object[source]¶ Function implementation of Cedar_Sync.
- Args:
local_model (List): List of client model parameters for aggregation. detect (bool): Whether to detect malicious updates. current_model (object): Current global model. num_layer (int): Number of layers involved in filtering. layer_weight (List): Weights to measure the importance of layers. stimulus_x (torch.tensor): Stimuli. require_judge_layer (List): Layers involved in filtering. upgrade_bool_list (pandas.DataFrame): Matrix of whether the layer is uploaded.
- Returns:
object: Updated model.
-
golf_federated.server.process.strategy.aggregation.function.SLMFedasyn(client_id: List, weight: dict, aggregate_percentage: dict, current_weight: List, current_acc: float, target_acc: float, func: str) → List[source]¶ Function implementation of SLMFed_Async.
- Args:
client_id (List): List of client IDs for aggregation. weight (dict): Dictionary of client model parameters for aggregation. aggregate_percentage (dict): Aggregate weights for each client. current_weight (List): Current global model parameters. current_acc (float): Current accuracy corresponding to the global model. target_acc (float): Target accuracy of the task. func (str): Function to adjust aggregation weights. Default as ‘other’.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
golf_federated.server.process.strategy.aggregation.function.SLMFedsyn(weight: List, aggregate_percentage: List, current_weight: List) → List[source]¶ Function implementation of SLMFed_Sync.
- Args:
weight (List): List of client model parameters for aggregation. aggregate_percentage (List): Aggregate weights for each client. current_weight (List): Current global model parameters.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
golf_federated.server.process.strategy.aggregation.function.fedasync(client_id: List, weight: dict, staleness: str, current_weight: List, current_round: int, client_round: dict, alpha: float, beta: float) → List[source]¶ Function implementation of FedAsync.
- Args:
client_id (List): List of uploaded client names. weight (dict): Dict of uploaded local model weight. staleness (str): Corresponds to the name of the function defined in FedAsync. current_weight (List): Current global model parameters. current_round (int): Number of current training round. client_round (dict): Number of global round corresponding to the model trained by each client. alpha (float): Corresponds to the parameter α defined in FedAsync. beta (float): Corresponds to the parameter β defined in FedAsync.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
golf_federated.server.process.strategy.aggregation.function.fedavg(weight: List, data_size: List) → List[source]¶ Function implementation of FedAVG, which directly averages the corresponding values of collected model parameters.
- Args:
weight (List): List of models to aggregate. data_size (List): List of data sizes of clients.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
golf_federated.server.process.strategy.aggregation.function.fedfd(client_id: List, weight: dict, client_round: dict, version_latest: int) → List[source]¶ Function implementation of FedFD, which weighted averages the corresponding values of collected model parameters.
- Args:
client_id (List): ID of clients that upload the models. weight (dict): Corresponding dictionary of client IDs and models to aggregate. client_round (dict): Corresponding dictionary of client IDs and number of training rounds for local models. version_latest (int): Latest model version.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
golf_federated.server.process.strategy.aggregation.function.fedprox_loss(model_library: str, w_global: List, w_local: List, miu: float = 1) → Callable[source]¶ The optimized loss function defined in FedProx.
- Args:
model_library (str): The library used to build model. w_global (List): Global model. w_local (List): Local model. miu (float): Corresponds to the parameter μ defined in FedProx. Default as 1.
- Returns:
Callable: Loss function.
golf_federated.server.process.strategy.aggregation.synchronous module¶
-
class
golf_federated.server.process.strategy.aggregation.synchronous.Cedar_syn(dataset_path: str, min_to_start: int = 2, num_class: int = 0, detect: bool = False)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedSynchronous FL with Cedar, inheriting from BaseFed class.
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
-
class
golf_federated.server.process.strategy.aggregation.synchronous.FedAVG(min_to_start: int = 2)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedSynchronous FL with FedAVG, inheriting from BaseFed class. From: “Communication-Efficient Learning of Deep Networks from Decentralized Data”
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
-
class
golf_federated.server.process.strategy.aggregation.synchronous.FedProx(miu: float = 1, min_to_start: int = 2)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedSynchronous FL with FedProx, inheriting from BaseFed class.
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-
-
class
golf_federated.server.process.strategy.aggregation.synchronous.SLMFed_syn(min_to_start: int = 2)[source]¶ Bases:
golf_federated.server.process.strategy.aggregation.base.BaseFedSynchronous FL with SLMFed, inheriting from BaseFed class.
-
aggregate(datadict: {'current_w': typing.List, 'parameter': <class 'queue.Queue'>, 'record': typing.List}) → List[source]¶ Abstract method for aggregation.
- Args:
datadict (dict): Data that will be input into the aggregation function, including current global model weights, client uploaded parameters and evaluation records.
- Returns:
List: The model generated after aggregation. And use a list to store the parameters of different layers.
-