Skip to content

Commit

Permalink
expose aggregate_fn to users for overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
SYangster committed Apr 30, 2024
1 parent ce79609 commit eff1d07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nvflare/app_common/workflows/base_fedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _check_results(results: List[FLModel]):
raise ValueError(f"Result from client(s) {empty_clients} is empty!")

@staticmethod
def _aggregate_fn(results: List[FLModel]) -> FLModel:
def aggregate_fn(results: List[FLModel]) -> FLModel:
aggregation_helper = WeightedAggregationHelper()
for _result in results:
aggregation_helper.add(
Expand Down
4 changes: 2 additions & 2 deletions nvflare/app_common/workflows/fedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def run(self) -> None:
results = self.send_model_and_wait(targets=clients, data=model)

aggregate_results = self.aggregate(
results, aggregate_fn=None
) # if no `aggregate_fn` provided, default `WeightedAggregationHelper` is used
results, aggregate_fn=self.aggregate_fn
) # using default aggregate_fn with `WeightedAggregationHelper`. Can overwrite self.aggregrate_fn with signature Callable[List[FLModel], FLModel]

model = self.update_model(model, aggregate_results)

Expand Down

0 comments on commit eff1d07

Please sign in to comment.