To keep our final project implementation code separate from the original source code, we have implemented all our logic in separate python scripts.
- Main program - fedml_experiments/standalone/domain_generalization/main_text.py
- Dataset - sorted_data_acl
- Backbone - fedml_api/standalone/domain_generalization/backbone/LSTM.py
- Dataset Handler - fedml_api/standalone/domain_generalization/datasets/amazon_product_reviews.py
- Federated Model - fedml_api/standalone/domain_generalization/models/utils/federated_model_text.py
- Dapper FL Text - fedml_api/standalone/domain_generalization/models/dapperfl_text.py
- Training - fedml_api/standalone/domain_generalization/utils/training_text.py
To install requirements:
pip install -r requirements.txt
UBELIX specific instructions:
module load OpenMPI/4.1.1-GCC-11.2.0
export OMPI_MCA_pml=^ucx
export PYTHONPATH=/path/to/the/repo/Spring25-DDL-DapperFL:$PYTHONPATH
We use wandb to keep a log of our experiments. If you don't have a wandb account, just install it and use it as offline mode.
pip install wandb
wandb off
To train the model(s) in the paper, run this command:
python main.py --model dapperfl --dataset fl_officecaltech --backbone resnet18
To train our text model version, run this command:
python main_text.py --model dapperfl_text --dataset fl_amazonreviews --backbone lstm
You can modify the arguments to run DapperFL on other settings. The arguments are described as follows:
| Arguments | Description |
|---|---|
prefix |
A prefix for logging. |
communication_epoch |
Total communication rounds of Federated Learning. |
local_epoch |
Local epochs for local model updating. |
parti_num |
Number of participants. |
model |
Name of FL framework. |
dataset |
Datasets used in the experiment. Options: fl_officecaltech, fl_digits. |
pr_strategy |
Pruning ratio used to prune local models. Options: 0 (without pruning), 0.1 ~ 0.9, AD (adaptive pruning). |
backbone |
Backbone global model. Options: resnet10, resnet18. |
alpha |
Coefficient alpha in co-pruning. Default: 0.9. |
alpha_min |
Coefficient alpha_min in co-pruning. Default: 0.1. |
epsilon |
Coefficient epsilon in co-pruning. Default: 0.2. |
reg_coeff |
Coefficient for L2 regularization. Default: 0.01. |
seed |
Random seed. |