PyTorch code for an efficient federated unlearning approach described in the paper "Goldfish: An Efficient Federated Unlearning Framework".
We recommended the following dependencies.
- python==3.8
- pytorch==1.11.0
- torchvision==0.12.0
- numpy==1.22.4
For more recommended dependencies, please refer to the file requirements.txt
.
Run train_[dataset_name].py
to obtain the trained models:
python train_[dataset_name].py
You can specify the number of training epochs by setting the epoch_num
in the file. If necessary, please modify the path to the dataset; otherwise, the code will automatically download the dataset to the default path when executed.
Run unlearning_[dataset_name].py
to perform the unlearning process:
python unlearning_[dataset_name].py
To customize the unlearning process, please make the following adjustments in the file:
- Modify the
epoch_num
value to specify the number of training epochs. - Modify the
teacher_net_path
to set the save path for the teacher model. - Modify the
forget_Proportion
to define the size of the forgetting dataset.
These configurations will allow you to tailor the unlearning process to your specific requirements. Ensure that the values are correctly set before running the training script to avoid any errors or unexpected results.
Run the Fed_mnist_even.py
file to perform federated learning under the condition of even local data distribution.
python Fed_mnist_even.py
Run the Fed_mnist_uneven.py
file to perform federated learning under the condition of uneven local data distribution.
python Fed_mnist_uneven.py
Run the Fed_mnist_unlearning.py
file to perform federated unlearning.
python Fed_mnist_unlearning.py
For detailed code explanations and best practices, please refer to