-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature(wxh): Add FedAMP algo and fix bugs. #25
base: main
Are you sure you want to change the base?
Conversation
XinghaoWu
commented
Oct 25, 2023
- Add FedAMP algo.
- Add the FedCAC paper link in README.md.
- Remove the default momentum in default_config.py to fix the bug when setting the optimizer to Adam.
2. Add FedCAC paper link in README.md. 3. Remove the default momentum in default_config.py to fix the bug when set optmizer to adam.
class FedAMPClient(BaseClient): | ||
""" | ||
Overview: | ||
This class is the base implementation of client in 'Bold but Cautious: Unlocking the Potential of Personalized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct this document, not FedCAC.
|
||
def __init__(self, args, client_id, train_dataset, test_dataset=None): | ||
""" | ||
Initializing train dataset, test dataset(for personalized settings). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct this document, the purpose is to get a copy of local model.
super(FedAMPClient, self).__init__(args, client_id, train_dataset, test_dataset) | ||
self.client_u = copy.deepcopy(self.model) | ||
|
||
def FedAMP_Loss_client(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the get_model_difference
function (defined in fling/utils/torch_utils.py ) for simplification.
from fling.utils.utils import weight_flatten | ||
|
||
@CLIENT_REGISTRY.register('fedamp_client') | ||
class FedAMPClient(BaseClient): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether this client is identical to FedProxClient
? What's the differences?
coef = torch.zeros(self.args.client.client_num) | ||
for j, mw in enumerate(self.client_ws): | ||
if i == j: continue | ||
sub = weights[i] - weights[j] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite it using fling.utils.get_model_difference
@@ -14,6 +15,13 @@ def client_sampling(client_ids: Iterable, sample_rate: float) -> List: | |||
) | |||
return participated_clients | |||
|
|||
def weight_flatten(model) -> torch.Tensor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that this function can be removed.
Reformat the code before final merge. |
Add example configs for cifar100, mnist and tiny-imagenet. |