Skip to content

Commit

Permalink
Merge pull request #67 from Xiao-Chenguang/flex-alg
Browse files Browse the repository at this point in the history
Use inplace add to avoid broke the reference to model parameters
  • Loading branch information
Xiao-Chenguang authored Nov 26, 2024
2 parents 02ea6ad + f230ff9 commit d372542
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fedmind/algs/fedavg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def _aggregate_updates(self, updates: list[dict]) -> dict:
"""
agg_update = sum([update["model_update"] for update in updates]) / len(updates)
agg_loss = sum([update["train_loss"] for update in updates]) / len(updates)
self._gm_params += agg_update
self._gm_params.add_(agg_update)
self.logger.info(f"Train loss: {agg_loss:.4f}")
return {"train_loss": agg_loss}

0 comments on commit d372542

Please sign in to comment.