Giter Club home page Giter Club logo

cgcl-codes / transferattacksurrogates Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 2.0 131 KB

The official code of IEEE S&P 2024 paper "Why Does Little Robustness Help? A Further Step Towards Understanding Adversarial Transferability". We study how to train surrogates model for boosting transfer attack.

Home Page: https://arxiv.org/abs/2307.07873

License: MIT License

Python 85.86% Shell 14.14%
adversarial-attacks adversarial-training black-box-attack data-augmentation distribution-shift gradient-regularization sharpness-aware-minimization transfer-attack

transferattacksurrogates's Introduction

TransferAttackSurrogates

The implementation of our IEEE S&P 2024 paper "Why Does Little Robustness Help? A Further Step Towards Understanding Adversarial Transferability"

Abstract

Adversarial examples for deep neural networks (DNNs) have been shown to be transferable: examples that successfully fool one white-box surrogate model can also deceive other black-box models with different architectures. Although a bunch of empirical studies have provided guidance on generating highly transferable adversarial examples, many of these findings fail to be well explained and even lead to confusing or inconsistent advice for practical use.

In this paper, we take a further step towards understanding adversarial transferability, with a particular focus on surrogate aspects. Starting from the intriguing “little robustness” phenomenon, where models adversarially trained with mildly perturbed adversarial samples can serve as better surrogates for transfer attacks, we attribute it to a trade-off between two dominant factors: model smoothness and gradient similarity. Our research focuses on their joint effects on transferability, rather than demonstrating the separate relationships alone. Through a combination of theoretical and empirical analyses, we hypothesize that the data distribution shift induced by off manifold samples in adversarial training is the reason that impairs gradient similarity.

Building on these insights, we further explore the impacts of prevalent data augmentation and gradient regularization on transferability and analyze how the trade-off manifests in various training methods, thus building a comprehensive blueprint for the regulation mechanisms behind transferability. Finally, we provide a general route for constructing superior surrogates to boost transferability, which optimizes both model smoothness and gradient similarity simultaneously, e.g., the combination of input gradient regularization and sharpnessaware minimization (SAM), validated by extensive experiments. In summary, we call for attention to the united impacts of these two factors for launching effective transfer attacks, rather than optimizing one while ignoring the other, and emphasize the crucial role of manipulating surrogate models.

Model Training

All the training methods reported in our paper are implemented in the train.py under the CIFAR_Train directory.

SAM

python train.py --arch resnet18 \
                --dataset cifar10 \
                --sam \
                --rho 0.1 \
                --save-dir ./cifar10-models/resnet18-sam-0.1 \
                --epoch 200

Adversarial Training (AT)

python train.py --arch resnet18 \
                --dataset cifar10 \
                --robust \
                --pgd-norm-type l2 \
                --pgd-radius 0.5 \
                --pgd-random-start \
                --pgd-steps 10 \
                --pgd-step-size 0.125 \
                --save-dir ./cifar10-models/resnet18-adv-0.5 \
                --epoch 200

Jacbian Regularization (JR)

Install jacobian_regularizer first:

pip install git+https://github.com/facebookresearch/jacobian_regularizer

python train.py --arch resnet18 \
                --dataset cifar10 \
                --reg \
                --reg-type jr \
                --jr-beta 0.05 \
                --save-dir ./cifar10-models/resnet18-jr-0.05 \
                --epoch 200

Input Regularization (IR)

python train.py --arch resnet18 \
                --dataset cifar10 \
                --reg \
                --reg-type ig \
                --ig-beta 0.1 \
                --save-dir ./cifar10-models/resnet18-ir-0.1 \
                --epoch 200

SAM & IR

python train.py --arch resnet18 \
                --dataset cifar10 \
                --reg \
                --reg-type ig \
                --ig-beta 0.1 \
                --sam \
                --rho 0.1 \
                --save-dir ./cifar10-models/resnet18-sam-0.1-ir-0.1 \
                --epoch 200

transferattacksurrogates's People

Contributors

yechao-zhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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