Home

Awesome

Drawing Robust Scratch Tickets: Subnetworks with Inborn Robustness Are Found within Randomly Initialized Networks

Yonggan Fu, Qixuan Yu, Yang Zhang, Shang Wu, Xu Ouyang, David Cox, Yingyan Lin

Accepted at NeurIPS 2021 [Paper Link].

Overview

Robust Scratch Ticket: The Existence

<p align="center"> <img src="images/existence.png" width="800"> </p>

Robust Scratch Ticket: The Property

<p align="center"> <img src="images/property.png" width="800"> </p>

Robust Scratch Ticket: The Application

<p align="center"> <img src="images/application.png" width="800"> </p>

Code Usage

Our codes support the adversarial search of RSTs and finetune RSTs with inherited/re-initialized model weights. Basic settings are listed in .yml files as shown in the dir config_rst which is specified by the arg --config. Most settings in .yml files can be overrided by specifying other args, e.g., --data path-to-dataset.

Prerequisites

See env.yml for the complete conda environment. Create a new conda environment:

conda env create -f env.yml
conda activate pytorch

Search/Finetune RSTs on CIFAR-10/100

python main.py --config config_rst/resnet18-usc-unsigned-cifar.yaml --multigpu 0 --set CIFAR10 --data path-to-data --lr_policy cifar_piecewise --epochs 160  --prune-rate target-prune-rate --name exp_name --attack_type pgd --task search

Note that --prune-rate is the ratio of remaining weights as reported in the paper.

python main.py --config config_rst/resnet18-usc-unsigned-cifar.yaml --multigpu 0 --set CIFAR10 --data path-to-data --lr_policy cifar_piecewise --epochs 160  --prune-rate target-prune-rate --name exp_name --attack_type pgd --task ft_inherit --pretrained path-to-searched-rst

The arg --pretrained specifies the checkpoint of the searched RST, which is not necessary if the finetuning and search process are in the same working directory.

python main.py --config config_rst/resnet18-usc-unsigned-cifar.yaml --multigpu 0 --set CIFAR10 --data path-to-data --lr_policy cifar_piecewise --epochs 160  --prune-rate target-prune-rate --name exp_name --attack_type pgd --task ft_reinit --pretrained path-to-searched-rst

Search RSTs on ImageNet

python main.py --config config_rst/resnet50-ukn-unsigned-imagenet.yaml --set ImageNet --data path-to-data --lr_policy multistep_lr_imagenet --epochs 90  --prune-rate target-prune-rate --name exp_name --attack_type pgd --alpha 2 --epsilon 4 --attack_iters 2 --val_every 5 --task search --automatic_resume

Search Robust Trained Tickets (RTTs)

python train_full.py --config config_rst/resnet18-usc-unsigned-cifar.yaml --multigpu 0 --set CIFAR10 --data path-to-data --epochs 160 --lr 0.1 --lr_policy cifar_piecewise --name exp_name --attack_type pgd

If --attack_type pgd is deleted, the training process will be on clean images. After acquiring the pretrained models, RTTs can be drawn via specifying --pretrained during the adversarial search process.

Test adversarial transferability between RSTs

python test_trans.py --config config_rst/resnet18-usc-unsigned-cifar.yaml --set CIFAR10 --data path-to-data --name exp_name --attack_type pgd --pretrained ckpt/resnet18_0.01.pth

Citation

@article{fu2021drawing,
  title={Drawing Robust Scratch Tickets: Subnetworks with Inborn Robustness Are Found within Randomly Initialized Networks},
  author={Fu, Yonggan and Yu, Qixuan and Zhang, Yang and Wu, Shang and Ouyang, Xu and Cox, David and Lin, Yingyan},
  journal={Advances in Neural Information Processing Systems},
  volume={34},
  year={2021}
}

Acknowledgement

Our codes are modified from [What’s Hidden in a Randomly Weighted Neural Network].