Home

Awesome

Understanding Rare Spurious Correlations in Neural Network

This repository contains the code of the experiments in the paper

Understanding Rare Spurious Correlations in Neural Network

Authors: Yao-Yuan Yang, Chi-Ning Chou, Kamalika Chaudhuri

Abstract

Neural networks are known to use spurious correlations such as background information for classification. While prior work has looked at spurious correlations that are widespread in the training data, in this work, we investigate how sensitive neural networks are to rare spurious correlations, which may be harder to detect and correct, and may lead to privacy leaks. We introduce spurious patterns correlated with a fixed class to a few training examples and find that it takes only a handful of such examples for the network to learn the correlation. Furthermore, these rare spurious correlations also impact accuracy and privacy. We empirically and theoretically analyze different factors involved in rare spurious correlations and propose mitigation methods accordingly. Specifically, we observe that $\ell_2$ regularization and adding Gaussian noise to inputs can reduce the undesirable effects.


Installation

pip3 install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
pip3 install -r requirements.txt

Scripts

Usage

Experiment options

Model options

Architectures

implementation: spurious_ml/models/torch_utils/archs/

Examples

Dataset options

Clean datasets: mnist, fashion, and cifar10

template: f'{clean_dataset}{spurious_pattern}-{n_spuious_examples}-{label}-{random_seed}'

Spurious pattern names

The name of each spurious pattern is different from the one used in the paper. Here, we provide a mapping.

Examples:

Commandline examples

python ./main.py --experiment train_classifier \
    --dataset mnistv8-3-0-0 --epochs 70 --random_seed 0 \
    --batch_size 128 --model ce-tor-LargeMLP --optimizer sgd --learning_rate 0.01 --momentum 0.9
python ./main.py --experiment group_influence \
    --dataset mnistv8-3-0-0 --epochs 70 --random_seed 0 \
    --batch_size 128 --model ce-tor-LargeMLP --optimizer sgd --learning_rate 0.01 --momentum 0.9 \
    --model_path {path_to_the_model_to_perform_data_deletion}
python ./main.py --experiment incremental_retraining \
    --dataset mnistv8-3-0-0 --epochs 140 --random_seed 0 \
    --batch_size 128 --model ce-tor-LargeMLP --optimizer sgd --learning_rate 0.01 --momentum 0.9 \
    --model_path {path_to_the_model_to_continue_training}

Continue training until the 140-th epoch

Citation

For more experimental and technical details, please check our paper

@article{yang2022understanding,
  title={Understanding Rare Spurious Correlations in Neural Network},
  author={Yao-Yuan Yang and Chi-Ning Chou and Kamalika Chaudhuri},
  journal={arXiv preprint arXiv:2202.05189},
  year={2022}
}