Skip to content

Commit

Permalink
Set initial_parameters as non-optional for FedAvgM (#2369)
Browse files Browse the repository at this point in the history
This change aims to better communicate to users the necessity of
`initial_parameters` in case of server-side optimization, as well as
expose which conditions must be met to enable server-side optimization.
  • Loading branch information
DanielCardeal committed Sep 25, 2023
1 parent 204a4fe commit 31218ac
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/py/flwr/server/strategy/fedavgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
accept_failures: bool = True,
initial_parameters: Optional[Parameters] = None,
initial_parameters: Parameters,
fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
evaluate_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
server_learning_rate: float = 1.0,
Expand Down Expand Up @@ -89,13 +89,17 @@ def __init__(
Function used to configure validation. Defaults to None.
accept_failures : bool, optional
Whether or not accept rounds containing failures. Defaults to True.
initial_parameters : Parameters, optional
initial_parameters : Parameters
Initial global model parameters.
server_learning_rate: float
Server-side learning rate used in server-side optimization.
Defaults to 1.0.
If either `server_learning_rate` != 1.0 or `server_momentum` !=
0.0, enables server-side optimization. Defaults
to 1.0.
server_momentum: float
Server-side momentum factor used for FedAvgM. Defaults to 0.0.
Server-side momentum factor used in server-side optimization. If
either `server_learning_rate` != 1.0 or `server_momentum` != 0.0,
enables server-side optimization. Defaults to 0.0.
"""
super().__init__(
fraction_fit=fraction_fit,
Expand Down

0 comments on commit 31218ac

Please sign in to comment.