Giter Site home page Giter Site logo

pytorch-backdoor-unlearning's Introduction

Pytorch-Backdoor-Unlearning

This repository contains code for our paper (Backdoor Defense with Machine Unlearning) implemented in Pytorch. This paper was accepted by INFOCOM 2022.

Citing this work

Liu Y, Fan M, Chen C, et al. Backdoor Defense with Machine Unlearning[J]. arXiv preprint arXiv:2201.09538, 2022.

Requirements

  • Python 3.9.2
  • Pytorch 1.9
  • Torchvision 0.1.8
  • Trojanvision 1.0.8

Instructions

Quick Start

We provide a demo for a quick start, directly running the main.py in this repo.

python main.py

Firstly, you need to install the above packages and enuring your environment is consistent with our environment (different environment may cause some bugs or inconsistent results of our paper).

Besides, the data of MNIST, Fashion-MNIST, CIFAR-10, and CIFAR-100 should stored (downloaded) in path "..//data".

Default attack method is Badnet with the $3 \times 3$ trigger adopted random position and initialization, where random position is more threat than fixed position.

Ideally, the accuracy and ASR of the obtained model trained with default setting (backdoored model) is about 85% and 100%.

Our defense method also is included in main.py and you will see the results reported in the paper.

If you want to reproduce more experiment results or used in your research, following the below instructions.

Training Backdoored Model

More information will quickly arrive.

Erasing Backdoor from the model using our method

More information will quickly arrive.

Other source code

Code for NAD (Neural Attention Distillation: Erasing Backdoor Triggers from Deep Neural Networks) refer to this site.

Code for GAN-based defense (Defending Neural Backdoors via Generative Distribution Modeling) refer to this site.

Code for Fine-Pruning defense is integrated in the library TroJanZoo.

pytorch-backdoor-unlearning's People

Contributors

fmy266 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ny1024

pytorch-backdoor-unlearning's Issues

gen_backdoor_mnist.py file does not exist in unlearning_backdoor.py, line 22, gen_backdoor_mnist

I find a file named "gen_backdoor.py" but didn't find a file named "gen_backdoor_mnist.py".
I change the code to:

# self.GM_model = gen_backdoor_mnist.GM(self.victimized_model, self.attack, search_param, ratio)
self.GM_model = gen_backdoor.GM(self.victimized_model, self.attack, search_param, ratio)

but still can't run the code correctly. 

```shell
Traceback (most recent call last):
  File "/home/user/code/backdoors/Pytorch-Backdoor-Unlearning/main.py", line 32, in <module>
    defense.run()
  File "/home/user/code/backdoors/Pytorch-Backdoor-Unlearning/unlearning_backdoor.py", line 30, in run
    self.unlearning_process()
  File "/home/user/code/backdoors/Pytorch-Backdoor-Unlearning/unlearning_backdoor.py", line 58, in unlearning_process
    for param1, param2 in self.victimized_model.parameters(), self.backup.parameters():
ValueError: too many values to unpack (expected 2)

lack of details about implementation and acc and asr problem

Hi, your work is really excellent and I am of great interest to it.
But your provided code is probably not enough to reproduce the result whose loss function and many setting is limited and I tried to implement it but finally get a bad result of it. could you give some more details or notes for the implements? thank you a lot anyway!

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.