GithubHelp home page GithubHelp logo

yanchb3 / advdefense_csc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gitbosun/advdefense_csc

0.0 1.0 0.0 8.07 MB

Code for "Adversarial Defense by Stratified Convolutional Sparse Coding"

Python 100.00%

advdefense_csc's Introduction

AdvDefense_CSC

Code for Adversarial Defense by Stratified Convolutional Sparse Coding.

This is an attack-agnostic adversarial defense based on input transformation. After getting adversarial examples from threaten model, we reconstruct adversarial images (optional: and clean images) with convolutional sparse coding to remove adversarial noise. After reconstruction, adversairal examples are projected to a quai-natural space wehere they share close perceptual features and network capturing features.

Sample

pipeline

Requirements

You need to install sporco to operate convolutional sparse coding,

Defense Process

1. Without Clustering

Here we don't use DAE to find a cluster that input image belongs to. After learning filter basis from natural images, we direcctly use this basis to reconstruct images.

2. With Clustering

We first train a Denosing Autoencoder with (64,64) natural images. Then we split all images to several clusters based on DAE latent features and learn a filter basis for each cluster. For each input image, we first resize it to (64, 64) and feed it to DAE to find the cluster its latent feature belongs to. Then we reconstruct the input with basis of its cluster.

Usage

recons_data.py

Given a folder with images, it reconstructs those images to another folder with the same image names. You need to specify te input path, output path and basis path in this python script. example:

python recons_data.py 64 8 0.2 32

basis

It saves some pre-learned filter basis from natural images. In this folder, we have basis for cifar, Imagenet(in resolution 224 and 64). In each subfoler, we have basis with different sparse coefficients. 64_p8_lm0.2.npy means this basis have 64 filters with size (8, 8) and it's learned under the sparse coefficient 0.2.

Results

CIFAR-10

cifar

ImageNet

imagenet

advdefense_csc's People

Contributors

gitbosun avatar

Watchers

James Cloos 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.