This framework implements the Label Leakage from Gradients (LLG) attack, a novel attack to extract ground-truth labels from shared gradients trained with mini-batch stochastic gradient descent for multi-class classification in Federated Learning. LLG is based on a combination of mathematical proofs and heuristics derived empirically. The attack exploits two properties that the gradients of the last layer of a neural network have: (P1) The direction of these gradients indicates whether a label is part of the training batch. (P2) The gradient magnitude can hint towards the number of occurrences of a label in the batch.
- Setup a clean Python
3.7.9environment with the tool of your choice (conda, venv, etc.). - Install required python libraries using:
pip install -r Code/requirements.txt - Initiate and update aDPtorch submodule:
git submodule initandgit submodule update
It is possible that the LLG code runs with newer python versions. However, don't use the most current, as opacus and torchcsprng tend to have a bit of a delay getting updated to work with newest python and/or torch versions.
- Choose an experiment from the table below.
- Prepare the detailed experiment parameters in
main.pyto fit your needs. - Execute the experiment:
python main.py -s <experiment_set_number> -g <gpu_id_if_avail> - Visualize the dump file(s):
python main.py -s <experiment_set_number> -d <path_to_dump_file(s)>
| set | description |
|---|---|
| 1,2 | batch size (untrained) |
| 3,4 | trained model |
| 5 | model architecture comparison |
| 6 | additive noise (untrained) |
| 7 | compression (untrained) |
| 8 | differential privacy (untrained) |
| 9 | federated training and trained defenses |
usage: main.py [-h] [-s SET] [-p PLOT] [-j JOB] [-d DIR] [-g GPU_ID]
Arguments for LLG Experiment
optional arguments:
-h, --help show this help message and exit
-s SET, --set SET experiment set (default=2)
-p PLOT, --plot PLOT number of files to be ploted (default=None)
-j JOB, --job JOB job to execute. either "experiment" or "visualize". (default="experiment")
-d DIR, --dir DIR directory or file to plot from. (default=None)
-g GPU_ID, --gpu_id GPU_ID cuda_id to use, if available (default=0)
- Aidmar Wainakh - LLG idea, guidance and suggestions during development
- Till Müßig - LLG idea, developing LLG and initial experiments as part of his Bachelor’s thesis and a seminar course
- Jens Keim - developing advanced experiments, refactoring, current maintainer
This repository is licensed under the MIT License.
This repo contains a markdown and a text version of the license.
In case of any inconstancies refer to the license's website.