-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implementing FedRep #127
Implementing FedRep #127
Conversation
… method. There is also a slight refactor of the base models for FedPer, MOON, and FedRep, as they all belong to the category of SequentiallySplit models, in some way. Also adding FedRep and Ditto to the smoke tests.
from fl4health.utils.load_data import load_mnist_data | ||
from fl4health.utils.metrics import Accuracy, Metric | ||
from fl4health.utils.sampler import MinorityLabelBasedSampler | ||
|
||
|
||
class MnistFedPerClient(MoonClient): | ||
class MnistFedPerClient(FedPerClient): |
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.
Changing this client to no longer inherit from MoonClient. I liked the idea of mixing them, because they are so related, but it can be a little confusing. This also means that we can rip out the need to remember to specify the exchanger when using vanilla FedPer. We can still use the MoonClient to combine the idea with FedPer, just removing it from the examples to reduce confusion.
@@ -56,10 +52,6 @@ def get_optimizer(self, config: Config) -> Optimizer: | |||
def get_criterion(self, config: Config) -> _Loss: | |||
return torch.nn.CrossEntropyLoss() | |||
|
|||
def get_parameter_exchanger(self, config: Config) -> ParameterExchanger: |
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.
Now appears in FedPerClient
@@ -1,31 +0,0 @@ | |||
import torch |
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.
Moved this model into the same file as that used for FedRep since they are both just sequentially split models but for different datasets (MNIST vs. CIFAR)
|
||
In this demo, APFL is applied to an augmented version of the MNIST dataset that is non--IID. The FL server expects three clients to be spun up (i.e. it will wait until three clients report in before starting training). Each client has a modified version of the MNIST dataset. This modification essentially subsamples a certain number from the original training and validation sets of MNIST in order to synthetically induce local variations in the statistical properties of the clients training/validation data. In theory, the models should be able to perform well on their local data while learning from other clients data that has different statistical properties. The proportion of labels at each client is determined by dirichlet distribution across the classes. The lower the beta parameter is for each class, the higher the degree of the label heterogeneity. | ||
In this demo, APFL is applied to an augmented version of the MNIST dataset that is non--IID. The FL server expects three clients to be spun up (i.e. it will wait until three clients report in before starting training). Each client has a modified version of the MNIST dataset. This modification essentially subsamples a certain number from the original training and validation sets of MNIST in order to synthetically induce local variations in the statistical properties of the clients training/validation data. In theory, the models should be able to perform well on their local data while learning from other clients data that has different statistical properties. The proportion of labels at each client is determined by Dirichlet distribution across the classes. The lower the beta parameter is for each class, the higher the degree of the label heterogeneity. |
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.
Dirichlet is the name of a German mathematician, hence the capitalization.
@@ -32,7 +32,7 @@ def __getitem__(self, index: int) -> Tuple[torch.Tensor, torch.Tensor]: | |||
return self.data[index], self.targets[index] | |||
|
|||
|
|||
class TestClient(InstanceLevelPrivacyClient): | |||
class ClientForTest(InstanceLevelPrivacyClient): |
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.
These classes are just renamed to address a warning in pytest that it can't "discover" these tests. It just uses a rudimentary GREP for the prefix "Test" to find tests. So the rename just reduces the warnings.
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 just put a few comments. Overall it is a vrry neat PR, so I approve it.
…base classes for FedPer, FedRep, and MOON to bury the flatten features functionality in the base class for SequentiallySplitModels. With this change in functionality the FedPer class became essentially a pass through. So I eliminated it and made some modifications for the FedPerClient to make it clear that a SequentiallySplitExchangeBaseModel was the right type to be used for this client. Also added a test for the FedPerClient and modified the fedper base test.
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.
Nice changes, just 2 comments and then good to go.
PR Type
Feature
Implementation of FedRep. This includes an example of the methods use, unit tests, and addition to the smoke tests.
Note: Most of the file changes are more very small typo fixes.
Clickup Ticket(s): Link(s) if applicable.
Tests Added
Added to the Smoke Tests
Tests have also been added in
tests/clients/test_fedrep_client.py