Code Monkey home page Code Monkey logo

etio's Introduction

Membership Inference Attacks and Generalization: A Causal Perspective

We propose the first approach to explain MI attacks and their connection to generalization based on principled causal reasoning. We offer causal graphs that quantitatively explain the observed MI attack performance achieved for 6 attack variants. This work is by Teodora Baluta, Shiqi Shen, S. Hitarth, Shruti Tople and Prateek Saxena, as published in CCS 2022.

ETIO

1. Install an environment manager

It is recommended to use an environment management tool like virtualenv to easily manage the project's requirements and avoid any conflicts with your system packages. If you are using virtualenv, run these commands to set up an environment:

$ cd into/your/project/folder
$ virtualenv -p python3 env
$ source env/bin/activate

This will activate an empty virtual environment. You can use deactivate to exit the environment. You can also use the following command to create a new environment:

$ python3 -m venv env

At this point, you will have an env directory for your virtual environment.

2. Install dependencies

In the root folder (where the requirements.txt file is), run this command to install all dependencies:

$ pip install -r requirements.txt

Install Cuda using the commands mentioned in the following.

Requirements

The main requirements are as follows:

Python 3.8.10

Python Packages

torch                   1.7.1+cu110
torchvision             0.8.2+cu110
tqdm                    4.61.2
matplotlib              3.4.2
scipy                   1.7.1

Command to install Cuda:

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
pip install tqdm matplotlib

3. Preparing Datasets and Training Models

  1. Preparing datasets: please run ./estimator/prepare_dataset.py
  2. Training models: please run ./trainer/train.py
  3. Computing bias & variance: plaese run ./estimator/estimator.py

More details about each step can be found in README.md in each folder (e.g., estimator and trainer).

4. Executing Attacks

Attacks can be performed with the scripts in the attack module. The details are in README.md file in attack folder.

Following attacks are available in this module:

  1. MLleaks Attack
  2. Oakland Shadow Model Attack
  3. Threshold Attack

5. Executing Defences for Attacks

The memguard defence code is in the defence module with the script memguard.py.

6. Collecting Statistics

We store the trained models and attack models in a folder with following structure:

    ├─────────────────────────────────── 
    │root_dir
    │── datasets
    │── mlleaks-attacks
    │   ├── mlleaks-attacks-wd_5e3
    │   │   ├── epoch_400
    │   │   └── epoch_500
    │   └── mlleaks-attacks-wd_5e4
    │   │   ├── epoch_400
    │   │   └── epoch_500
    ├── mlleaks_top3-attacks
    │   ├── mlleaks_top3-attacks-wd_5e3 
    │   │   ├── epoch_400
    │   │   ├── epoch_500 
    │   └── mlleaks_top3-attacks-wd_5e4 
    │       ├── epoch_400 
    │       └── epoch_500
    ├── oak17-attacks/
    │   ├── oak17-attacks-wd_5e3
    │   │   ├── epoch_400
    │   │   └── epoch_500
    │   └── oak17-attacks-wd_5e4
    │       ├── epoch_400
    │       └── epoch_500
    ├───────────────────────────────────

To generate the summary of all trained models, along with the attacks performed over them, run the following script:

python3 analyze_attacks/parse_summary.py <base_dir> <summary_dir>

Executing this script will store all the summary inside the folder <summary_dir>/full-summary.csv.

How to Cite

If you use ETIO, please cite our work.

etio's People

Contributors

teobaluta avatar hitarths 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.