This repository contains the official implementation of our paper titled "Membership Inference Attacks for Unseen Classes".
Create and activate the conda environment using:
conda env create -f environment.yml
conda activate qmiaenv- Download into
datafrom: https://datashare.ed.ac.uk/handle/10283/3192 - Combine the train and validation splits into a single folder named
trainval - Rename the directory to
data/cinic10
- Automatically downloaded by TorchVision within the dataloader
- Download by running the
download_imagenet_folder()function provided indata_utils.py
- Download into
datafrom: https://github.com/privacytrustlab/datasets/blob/master/dataset_purchase.tgz - Run
python convert_purchase_dataset.py
- Download into
datafrom: https://github.com/privacytrustlab/datasets/blob/master/dataset_texas.tgz - Run
python convert_texas_dataset.py
- Automatically downloaded by HuggingFace within the dataloader.
- Run
python convert_20news_dataset.py
Run test_dropout.sh with the following variables:
BASE_ARCHITECTURE=cifar-resnet-50
QMIA_ARCHITECTURE=facebook/convnext-tiny-224
BASE_DATASET=cinic10/0_16
ATTACK_DATASET=cinic10/0_16
DROPPED_CLASSES=(0) # Change to (1), (2), ... (9) for other classesResults will be stored in:
models/mia/base_cinic10/0_16/cifar-resnet-50/attack_cinic10/0_16/facebook/convnext-tiny-224/score_fn_top_two_margin/loss_fn_gaussian/cls_drop_###/predictions/plots
Run test_dropout.sh with the following variables:
BASE_ARCHITECTURE=cifar-resnet-50
QMIA_ARCHITECTURE=facebook/convnext-tiny-224
BASE_DATASET=cifar20/0_16
ATTACK_DATASET=cifar20/0_16
DROPPED_CLASSES=(0) # Change to (1), (2), ... (19) for other classesNote: CIFAR-20 refers to CIFAR-100 superclasses.
Results will be stored in:
models/mia/base_cifar20/0_16/cifar-resnet-50/attack_cifar20/0_16/facebook/convnext-tiny-224/score_fn_top_two_margin/loss_fn_gaussian/cls_drop_###/predictions/plots
Run test_dropout.sh with the following variables:
BASE_ARCHITECTURE=resnet-50
QMIA_ARCHITECTURE=facebook/convnext-tiny-224
BASE_DATASET=imagenet-1k/0_16
ATTACK_DATASET=imagenet-1k/0_16
DROPPED_CLASSES=("0-10") # Change to "0-30", "0-50", ... "0-990" for other rangesResults will be stored in:
models/mia/base_imagenet-1k/0_16/resnet-50/attack_imagenet-1k/0_16/facebook/convnext-tiny-224/score_fn_top_two_margin/loss_fn_gaussian/cls_drop_0to###/predictions/plots
Run test_scarcity.sh with the following variables:
BASE_ARCHITECTURE=resnet-50
QMIA_ARCHITECTURE=facebook/convnext-tiny-224
BASE_DATASET=imagenet-1k/0_16
ATTACK_DATASET=imagenet-1k/0_16
CLS_SAMPLES=1 # Change to 5, 10, ... 200 for different sample sizesResults will be stored in:
models/mia/base_imagenet-1k/0_16/resnet-50/attack_imagenet-1k/0_16/facebook/convnext-tiny-224/score_fn_top_two_margin/loss_fn_gaussian/cls_drop_none_samples_###/predictions/plots
Run test_dropout_tabular.sh with the following variables:
BASE_ARCHITECTURE=mlp-texas-small
QMIA_ARCHITECTURE=mlp-texas-small
BASE_DATASET=texas/0_16
ATTACK_DATASET=texas/0_16Run test_dropout_text.sh with the following variables:
BASE_ARCHITECTURE=gpt2-seqcls-lora
QMIA_ARCHITECTURE=text-mlp-small #text-distilgpt2
BASE_DATASET=20newsgroups/0_16
ATTACK_DATASET=20newsgroups/0_16Navigate to the notebooks directory and run the following Jupyter notebooks:
cd notebooks/
jupyter notebook explore_embeddings.ipynb
jupyter notebook explore_embeddings_c20.ipynb
jupyter notebook explore_embeddings_inet.ipynb