Add weighted aggregation, early stopping and persistent logging #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Summary of Changes:
I have implemented several key enhancements to the Federated Learning (FL) Aggregator component to improve the training process's efficiency, fairness, and transparency. The main changes include:
Weighted Aggregation by Dataset Size:
Early Stopping Mechanism:
early_stopping_patience
).Aggregator State Persistence (
agg_state.json
):agg_state.json
.Dashboard/Metric Setup:
public/fl/<project_name>
), copy dashboard files, and track accuracy metrics inaccuracy_metrics.json
.Bug Fixes and Miscellaneous Improvements:
NameError
by ensuring thejson
module is imported where necessary.training_loss_round_{round_num}.json
is correctly generated and moved to the public folder, making training loss logs accessible after project completion.Motivation:
These enhancements aim to make the federated learning pipeline more robust, fair, and efficient. Weighted aggregation ensures that models are influenced appropriately based on the data contributed, while early stopping conserves computational resources. Persisting the aggregator state enhances reliability, and the improved logging and dashboard setup aids in monitoring and analyzing the training process effectively.
Additional Context:
If this PR closes any open issues, please tag them accordingly (e.g.,
Closes #123
).Affected Dependencies
json
module for handling JSON operations.How has this been tested?
Unit Tests:
training_loss_round_{round_num}.json
is correctly created and updated during each training round.dataset_size.json
is accurately generated and used for weighted aggregation.Integration Tests:
Manual Testing:
agg_state.json
properly records and updates the best accuracy and no-improvement round count.public/fl/<project_name>
folder to verify that training loss and accuracy metrics are displayed correctly.Instructions to Reproduce:
Set Up:
Run Training:
training_loss_round_{round_num}.json
is being generated and copied to the public folder.Verify Aggregation:
dataset_size.json
from each client and performs weighted aggregation.Review Logs and Metrics:
public/fl/<project_name>
folder to review the training loss JSON files and the accuracy metrics dashboard.