Code Monkey home page Code Monkey logo

learning_to_invert's Introduction

Learning To Invert: Simple Adaptive Attacks for Gradient Inversion in Federated Learning

This code corresponds to the following paper:

Ruihan Wu, Xiangyu Chen, Chuan Guo, and Kilian Q. Weinberger. Learning To Invert: Simple Adaptive Attacks for Gradient Inversion in Federated Learning. UAI 2023.

1. Reproduce the Results of Vision Dataset (Table 1)

1.1 CIFAR10 and LeNet

To reproduce the results in Table 1 for CIFAR10 and LeNet, run the following script for B=1

python main_learn_dlg.py --lr 1e-4 --epochs 200 --leak_mode $leak_mode --model MLP-3000 --dataset CIFAR10 --batch_size 256 --shared_model LeNet

by setting leak_mode as None, sign, prune-0.99, gauss-0.1.

Run the script below for B=4

python main_learn_dlg.py --lr 1e-4 --epochs 5000 --leak_mode $leak_mode --model MLP-10000 --dataset CIFAR10 --batch_size 256 --shared_model LeNet

by setting leak_mode as batch-4, sign-batch-4, prune-0.99-batch-4, gauss-0.1-batch-4.

1.2 CIFAR10 and ResNet20

To reproduce the results in Table 1 for CIFAR10 and ResNet, run the following script for B=1

python main_learn_dlg_large_model.py --lr 1e-4 --epochs 40 --leak_mode $leak_mode --model MLP-3000 --dataset CIFAR10-hash --batch_size 256 --shared_model ResNet20

by setting leak_mode as None, sign, prune-0.99, gauss-0.1.

Run the following script for B=4

python main_learn_dlg_large_model.py --lr 1e-4 --epochs 200 --leak_mode prune-0.99-batch-4 --model MLP-3000 --dataset CIFAR10-hash --batch_size 256 --shared_model ResNet20

by setting leak_mode as batch-4, sign-batch-4, prune-0.99-batch-4, gauss-0.1-batch-4.

1.3 OOD Auxiliary Data

To reproduce the results in Table 2, run this script

python main_learn_dlg.py --lr 1e-4 --epochs 200 --leak_mode $leak_mode --model MLP-3000 --dataset CIFAR10 --shared_model LeNet --batch_size 256 --trainset ood

by setting leak_mode as None, sign, prune-0.99, gauss-0.1.

1.4 Evaluation with Different Metrics for Vision Datasets

Please check the Jupyter notebook Results--Vision.ipynb

2. Reproduce the Results of Language Dataset (Table 1)

2.1 COLA and BERT

To reproduce the results in Table 1 for COLA and BERT, run the following script

python main_learn_dlg_large_model.py --epochs 100 --batch_size 16 --dataset cola-hash --shared_model BERT --model NLPMLP-600-1000 --lr $lr --leak_mode $leak_mode

by setting (leak_mode, lr) as (None, 1e-3), (sign, 1e-5), (prune-0.99, 1e-3), (gauss-0.001, 1e-4).

2.2 Wikitext and 3-Layers Transformers

To reproduce the results in Table 1 for COLA and BERT, run the following script

python main_learn_dlg_large_model.py --epochs 100 --batch_size 64 --dataset wikitext-hash --shared_model Transformer --model NLPMLP-600-1000 --lr $lr --leak_mode $leak_mode

by setting (leak_mode, lr) as (None, 1e-3), (sign, 1e-5), (prune-0.99, 1e-3), (gauss-0.001, 1e-4).

2.3 OOD Auxiliary Data

Run the scripts in 2.1 or 2.2 by setting dataset as cola-pseudo-hash or wikitext-0.1-pseudo-hash respectively.

2.4 Evaluation with Different Metrics for Language Datasets

Please check the Jupyter notebook Results--Language.ipynb

Acknowledgement

We would like to thank the authors of Breaching, from where we use their federated learning framework in our experiments for language datasets and models.

learning_to_invert's People

Contributors

wrh14 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.