Skip to content
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

Update document and the set up script #22

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 6 additions & 60 deletions CI-install.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/bin/bash
set -ex

# install pyflakes to do code error checking
echo "pip3 install pyflakes --cache-dir $HOME/.pip-cache"
pip3 install pyflakes --cache-dir $HOME/.pip-cache
source "$HOME/miniconda3/etc/profile.d/conda.sh"

# Conda Installation
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
source "$HOME/miniconda/etc/profile.d/conda.sh"
hash -r
conda config --set always_yes yes --set changeps1 no
conda config --set always_yes yes #--set changeps1 no
conda update -q conda
conda info -a

echo "conda create -n fedml python=3.7.4"
conda create -n fedml python=3.7.4
echo "conda create -n feddrift python=3.7.4"
conda create -n feddrift python=3.7.4

echo "conda activate fedml"
conda activate fedml
echo "conda activate feddrift"
conda activate feddrift

# Install PyTorch (please visit pytorch.org to check your version according to your physical machines
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
Expand All @@ -42,50 +35,3 @@ cd ./../../../

# Install wilds package (still have to download the dataset separately)
pip install wilds

# install the dataset
# 1. MNIST
cd ./data/MNIST
sh download_and_unzip.sh
cd ../../

# 2. FederatedEMNIST
cd ./data/FederatedEMNIST
sh download_federatedEMNIST.sh
cd ../../

# 3. shakespeare
cd ./data/shakespeare
sh download_shakespeare.sh
cd ../../


# 4. fed_shakespeare
cd ./data/fed_shakespeare
sh download_shakespeare.sh
cd ../../

# 5. fed_cifar100
cd ./data/fed_cifar100
sh download_fedcifar100.sh
cd ../../

# 6. stackoverflow
cd ./data/stackoverflow
sh download_stackoverflow.sh
cd ../../

# 7. CIFAR10
cd ./data/cifar10
sh download_cifar10.sh
cd ../../

# 8. CIFAR100
cd ./data/cifar100
sh download_cifar100.sh
cd ../../

# 9. CINIC10
cd ./data/cinic10
sh download_cinic10.sh > cinic10_downloading_log.txt
cd ../../
47 changes: 47 additions & 0 deletions DATA-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

# install the dataset
# 1. MNIST
cd ./data/MNIST
sh download_and_unzip.sh
cd ../../

# 2. FederatedEMNIST
cd ./data/FederatedEMNIST
sh download_federatedEMNIST.sh
cd ../../

# 3. shakespeare
cd ./data/shakespeare
sh download_shakespeare.sh
cd ../../


# 4. fed_shakespeare
cd ./data/fed_shakespeare
sh download_shakespeare.sh
cd ../../

# 5. fed_cifar100
cd ./data/fed_cifar100
sh download_fedcifar100.sh
cd ../../

# 6. stackoverflow
cd ./data/stackoverflow
sh download_stackoverflow.sh
cd ../../

# 7. CIFAR10
cd ./data/cifar10
sh download_cifar10.sh
cd ../../

# 8. CIFAR100
cd ./data/cifar100
sh download_cifar100.sh
cd ../../

# 9. CINIC10
cd ./data/cinic10
sh download_cinic10.sh > cinic10_downloading_log.txt
cd ../../
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,56 @@ Empirical evaluation shows that our solutions achieve significantly higher accur

This repository is built on top of a federated learning research platform, [FedML](https://github.com/FedML-AI/FedML).

# Setup Environment

Our installation script is based on [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/). Please modify the script according to your package manager.

```
$ ./CI-install.sh
```

Our expeirments are tested with Python 3.7.4 and PyTorch 10.2. You can also install the GPU-enabled PyTorch by modifying the script above.

The above script will create a conda environment named `feddrift` and install all the required packages. Please activate the environment before running any experiments.

```
$ conda activate feddrift
```

# Running Experiments

We use [Weights & Biases](https://wandb.ai/site) to log experiments. Please create an account and log in before running an experiment.

```
$ wandb login
```

To run an experiment, please use the following command:

```
$ cd fedml_experiments/distributed/fedavg_cont_ens
$ ./run_fedavg_distributed_pytorch.sh ${CLIENT_NUM} ${WORKER_NUM} ${SERVER_NUM} ${GPU_PER_SERVER} ${MODEL} ${DATA_DIST} ${ROUND} ${EPOCH} ${BATCH_SIZE} ${LR} ${DATASET} ${DATA_DIR} ${SAMPLE_NUM} ${NOISE_PROB} ${ONLY_TEST_ONE_CLIENT} ${TOTAL_ITER} ${CONCEPT_NUM} ${RESET_MODEL} ${DRIFT_TOGETHER} ${DRIFT_ALGO} ${DRIFT_ALGO_ARG} ${TIME_STRETH} ${DUMMY_ARG} ${CHANGE_POINT}
```

For example, running FedDrift for SEA-4 dataset and change point **A**:

```
$ ./run_fedavg_distributed_pytorch.sh 10 10 1 4 fnn homo 200 5 500 0.01 sea "./../../../data/" 100 0 0 10 4 0 0 softcluster H_A_C_1_10_0 1 0 A
```

The major algorithms we implemented are listed here (in the form of `${DRIFT_ALGO}` + optionally `${DRIFT_ALGO_ARG}`):

* `win-1`: Window method (one time step)
* `win-2`: Window method (two time step)
* `all`: Oblivous method (using all training data)
* `dsurf`: [DriftSurf](https://proceedings.mlr.press/v139/tahmasbi21a/tahmasbi21a.pdf)
* `aue`: [Accuracy Updated Ensemble](https://link.springer.com/chapter/10.1007/978-3-642-21222-2_19)
* `kue`: [Kappa Updated Ensemble](https://link.springer.com/article/10.1007/s10994-019-05840-z)
* `softcluster` + `cfl_0.1_win-1`: Clustered federated learning
* `softclusterwin-1` + `hard-r`: [IFCA](https://arxiv.org/abs/2006.04088)
* `ada` + `win-1_iter` [Adaptive-FedAvg](https://ieeexplore.ieee.org/document/9533710)


# Reference Papers

If you use our code in your work, we would appreciate a reference to the following papers
Expand Down
12 changes: 0 additions & 12 deletions fedml_experiments/distributed/fedavg_cont_ens/README.md

This file was deleted.

Empty file.
12 changes: 0 additions & 12 deletions fedml_experiments/distributed/fedavg_cont_one/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion fedml_mobile/server/executor/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ paho-mqtt==1.5.0
Celery==5.2.2
pandas==1.1.3
setproctitle
sklearn