Code for paper - [Federated Learning on Non-IID Data with Local-drift Decoupling and Correction]
We provide code to run FedDC, FedAvg, FedDyn, Scaffold, and FedProx methods.
- Install the libraries listed in requirements.txt
pip install -r requirements.txt
We give datasets for the benchmark, including CIFAR10, CIFAR100, MNIST, EMNIST-L and the synthetic dataset.
You can obtain the datasets when you first time run the code on CIFAR10, CIFAR100, MNIST, synthetic datasets. EMNIST needs to be downloaded from this link.
For example, you can follow the following steps to run the experiments:
python example_code_mnist.py
python example_code_cifar10.py
python example_code_cifar100.py
- Run the following script to run experiments on the MNIST dataset for all above methods:
python example_code_mnist.py
- Run the following script to run experiments on CIFAR10 for all above methods:
python example_code_cifar10.py
- Run the following script to run experiments on CIFAR100 for all above methods:
python example_code_cifar10.py
- To show the convergence plots, we use the tensorboardX package. As an example to show the results which stored in "./Folder/Runs/CIFAR100_100_23_iid_":
tensorboard --logdir=./Folder/Runs/CIFAR10_100_23_iid
- Get the url, and then enter the url in to the web browser, for example "http://localhost:6006/".
Modify the DatasetObject() function in the example code. CIFAR-10 IID, 100 partitions, balanced data
data_obj = DatasetObject(dataset='CIFAR10', n_client=100, seed=17, rule='iid', unbalanced_sgm=0, data_path=data_path)
CIFAR-10 Dirichlet (0.3), 100 partitions, balanced data
data_obj = DatasetObject(dataset='CIFAR10', n_client=100, seed=47, unbalanced_sgm=0, rule='Drichlet', rule_arg=0.3, data_path=data_path)
The FedDC method is implemented in utils_methods_FedDC.py
. The baseline methods are stored in utils_methods.py
.
@inproceedings{
gao2022federated,
title={FedDC: Federated Learning with Non-IID Data via Local Drift Decoupling and Correction},
author={Liang Gao and Huazhu Fu and Li Li and Yingwen Chen and Ming Xu and Cheng-Zhong Xu},
booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
year={2022}
}