KarhouTam / FL-bench

Benchmark of federated learning. Dedicated to the community. 🤗
GNU General Public License v3.0
503 stars 82 forks source link

FedPer - Set split point of neural network at different locations #33

Closed WilliamLindskog closed 1 year ago

WilliamLindskog commented 1 year ago

Hi there!

How can I set the split point at different locations in a neural network e.g. ResNet18? For example, in their paper (see Figure 4a&b), they use different amount of layers in the classifier, thus different amount of layers in the base.

Is this already implemented?

Best regards, W

KarhouTam commented 1 year ago

Hi, @WilliamLindskog.

You can customize the self.classifier in model class.

https://github.com/KarhouTam/FL-bench/blob/a007582e31507ba0bd38fde6710927063c45a1ac/src/config/models.py#L262-L266

but please ensure that the self.base and self.classifier contain all modules in your model.

WilliamLindskog commented 1 year ago

Hi, @KarhouTam,

Thank you for your prompt answer. With regards to ResNet, if I were to put the split point somewhere else rather than the final layer, would the following functions forward, get_all_features, and get_final_features generalize or would I need to customize them as well?

KarhouTam commented 1 year ago

You do not need to change these methods. These methods are not called by FedPer, except forward(),which should work properly if you set the base and classifier well.