This code can be used to reproduce the findings in
Perfectly Accurate Membership Inference by a Dishonest Central Server in Federated Learning
(arXiv:2203.16463).
- Set up a Python environment that satisfies
requirements.txt
. - Start a Jupyter Notebook in
./
. - Navigate to
main.ipynb
. - Change the parameters as necessary and perform the experiment.
- The results are saved in
output/
. - The same notebook
main.ipynb
can be used to print the results.
The original values are saved in results.orig.json
and can also be explored.
A Dockerfile
is included to provide a containarized version of the code, taking care of the creation and setting up of the Python environment with all the required packages. A working Docker environment is needed. There are several tutorials for setting up a docker installation, e.g., this one. The following guide has been written for a Linux based system.
Steps required to run the Jupyter Notebook in a docker container:
- Navigate to the folder where the Dockerfile is stored (root directory of this repository);
- Execute
This downloads the environment and python packages.
foo@bar:~$ DOCKER_BUILDKIT=1 docker build -t dishonest_mia .
- The following command launches the container and the Jupyter notebook (since it is launced with no browser support, the information about the token is also displayed at this point):
foo@bar:~$ docker run --network host -e port=8888 dishonest_mia
- Open a browser (in the local machine) and browse to http://localhost:8888. The login token can be found in the docker output.
To reproduce all results in the paper, main.py
can be used:
- Set up a Python environment that satisfies
requirements.txt
. - Call
foo@bar:~$ python main.py 'optimizer=glob(*)' 'dataset=glob(*)' "param.batches=1,4,16,64,256" # different batchsizes foo@bar:~$ python main.py 'optimizer=glob(*)' 'dataset=glob(*)' "param.epochs=1,2,4" # different no. of epochs foo@bar:~$ python main.py 'optimizer=glob(*)' 'dataset=glob(*)' "param.top_j=1,2,8,16" # different M
- Results are saved in
output/
. - Call
foo@bar:~$ python process.py
- Results are available in
output/results.json
. They can be explored using themain.ipynb
notebook.
- You might need to download the CelebA dataset to
datasets/
manually due to a bug. - We disable the use of TensorFloat-32:
TF32 reduces the floating point precision dramatically. On modern platforms pytorch uses this feature by default. Using our method with
torch.backends.cuda.matmul.allow_tf32 = False torch.backends.cudnn.allow_tf32 = False
allow_tf32 = True
would require a largerepsilon
to account for the decreased precision.
File/Directory | Description |
---|---|
main.py |
Main executable. Configuration can be found in conf/ . By default, results are saved in *.json files in output/ . |
process.py |
script that merges the results in output/ into output/results.json . |
client.py |
Implements the flower -client. |
dishonest_server.py |
Implements the dishonest server as a flwr.flwr.server.strategy.Strategy . |
util.py |
Utility functions. |
requirements.txt |
Python requirements. |
results.json.orig |
Original results.json . |
README.md |
You are here. |
workaround.py |
Workaround for a missing feature in the current flower implementation. |
conf/ |
Configuration YAML files. |
Dockerfile |
Allows to build a docker container to run jupyter. |
main.ipynb |
Juptyer notebook to run individual experiments and display the results. |
duplicates.ipynb |
Jupyter notebook to explore the duplicate images in CIFAR100 and CelebA. |
duplicates.json |
List of duplicates in training and/or testing sets of CIFAR100 and CelebA. |