Giter VIP home page Giter VIP logo

nlb's Introduction

No Label Backdoor

This is the official repository for "How to Craft Backdoors with Unlabeled Data Alone?" by Yifei Wang*, Wenhan Ma*, Stefanie Jegelka, Yisen Wang.

illustration

Requirements

torch==1.10.0
torchvision==0.11.1
einops
pytorch-lightning==1.5.3
torchmetrics==0.6.0
lightning-bolts>=0.4.0
tqdm
wandb
scipy
timm

Run on CIFAR-10

Step 1:

Split training set into pretraining set and downstream set. Run python ./misc/cifar10_split.py

Step 2:

Pretrain the clean encoder on pretraining set. Run the script in script/cifar10_encoder

Step 3:

Select the poison subset. Run the script in script/cifar10_poison

Step 4:

Pretrain the backdoor encoder on pretraining set with poison subset. Run the script in script/cifar10_pretrain

Step 5:

Train the classifier. Run the script in script/cifar10_linear

Run on ImageNet-100

Step 1:

Split training set into pretraining set and downstream set. Run

python ./misc/imagnet_script/in100_split.py

Create a copy with poison. Run

python ./misc/imagnet_script/in100_add_trigger.py

Create a folder with soft link to the clean dataset. Run

python misc/imagnet_script/in100_link.py

Step 2:

Pretrain the clean encoder on pretraining set. Run the script in script/cifar10_encoder

Step 3:

Select the poison subset. Run the script in script/cifar10_poison

Step 4:

Create a folder with soft link to the clean dataset and poison subset. Run

python misc/imagnet_script/in100_link_poison.py

Step 5:

Pretrain the backdoor encoder on pretraining set with poison subset. Run the script in script/cifar10_pretrain

Step 6:

Train the classifier. Run the script in script/cifar10_linear

Citation

If you find this useful in your research, please consider citing:

@misc{wang2024craft,
      title={How to Craft Backdoors with Unlabeled Data Alone?}, 
      author={Yifei Wang and Wenhan Ma and Stefanie Jegelka and Yisen Wang},
      year={2024},
      eprint={2404.06694},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

Acknowledgement

This repo is based upon the following repository:

nlb's People

Contributors

cutenpc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.