This is a set of instructions for getting started with the project.
First you need to clone the project into whatever directory you prefer.
git clone https://github.com/RicoBorra/FederatedLearningProject
Then, for the following operations, move into the project folder.
cd FederatedLearningProject
This creates the virtual enviroment within a directory env
.
python -m venv env
Then you can activate the environment.
source env/bin/activate
Alternatively, in case of fish shell.
source env/bin/activate.fish
Automatically install all required packages.
pip install -r requirements.txt
There are two ways for importing the dataset.
Create dataset directory
cd data/femnist
Run the following commands to generate the datasets (and download the necessary files if missing)
To generate the non-iid distribution
./preprocess_parquet.sh -s niid --sf 1.0 -k 0 -t sample
To generate the iid distribution
./preprocess_parquet.sh -s iid --sf 1.0 -k 0 -t sample
Go back to parent directory of the project
cd -
Download zipped file.
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1AXJ5uuswGkv9dzVGMAJGRbGViWZFgImE' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1AXJ5uuswGkv9dzVGMAJGRbGViWZFgImE" -O compressed.zip && rm -rf /tmp/cookies.txt
Unzip file and remove zipped dataset.
unzip compressed.zip -d data/femnist/
rm -rf compressed.zip
Execute the following command to login with API key b578cc4325e4b0652255efe8f2878be1d5fad2f2
.
wandb login b578cc4325e4b0652255efe8f2878be1d5fad2f2
This will provide automatic access and log to the Weights & Biases platform for model and experiments tracking.
Run the application and test the model.
python main.py --niid --seed 0 --dataset femnist --model cnn \
--num_rounds 1000 \
--num_epochs 1 \
--clients_per_round 10 \
--print_train_interval 1000 --print_test_interval 1000 \
--eval_interval 10 --test_interval 10
By tweaking the parameters, we can have multiple experiments and outcomes.