Coder Social home page Coder Social logo

liuyuqinggg / per-fedavg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karhoutam/per-fedavg

0.0 1.0 0.0 35 KB

PyTorch Implementation of Personalized federated learning with theoretical guarantees: A model-agnostic meta-learning approach

License: MIT License

Python 100.00%

per-fedavg's Introduction

Personalized federated learning with theoretical guarantees: A model-agnostic meta-learning approach [NIPS 2020]

PyTorch Implementation of Per-FedAvg.

For simulating Non-I.I.D scenario, the dataset is split by labels and each client has only two classes of data.

It’s just a toy demo for demonstrating algorithm, so take it easy. 🀣

Requirements

torch~=1.10.2
path~=16.4.0
numpy~=1.21.2
fedlab~=1.1.4
torchvision~=0.11.3
rich~=12.2.0
pip install -r requirements.txt

Preprocess dataset

MNIST and CIFAR-10 is prepared.🌟

cd data; python preprocess.py

The way of preprocessing is adjustable, more details in each dataset folder's preprocess.py.

Run the experiment

Before run the experiment, please make sure that the dataset is downloaded and preprocessed already.

It’s so simple.πŸ€ͺ

python main.py

Hyperparameters

--global_epochs: Num of communication rounds. Default: 200

--local_epochs: Num of local training rounds. Default: 4

--pers_epochs: Num of personalization rounds (while in evaluation phase). Default: 1

--dataset: Name of experiment dataset. Default: mnist

--fraction: Percentage of training clients in all alients. Default: 0.9

--client_num_per_round: Num of clients that participating training at each communication round. Default: 5

--alpha: Learning rate $\alpha$ in paper. Default: 0.01

--beta: Learning rate $\beta$ in paper. Default: 0.001

--gpu: Non-zero value for using CUDA; 0 for using CPU. Default: 1

--batch_size: Batch size of client local dataset. Default: 40.

--eval_while_training: Non-zero value for performing evaluation while in training phase. Default: 1

--valset_ratio: Percentage of validation set in client local dataset. Default: 0.1

--hf: Non-zero value for performing Per-FedAvg(HF); 0 for Per-FedAvg(FO). Default: 1

--seed: Random seed for init model parameters and selected clients. Default: 17

--log: Non-zero value for recording experiment's output to a .html file in ./log. Default: 0

per-fedavg's People

Contributors

karhoutam avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.