Git Product home page Git Product logo

salehi_submitted_2020's Introduction

ARAE: Adversarially Robust Training of Autoencoders Improves Novelty Detection

This repository contains code to reproduce the main experiments of our paper ARAE: Adversarially Robust Training of Autoencoders Improves Novelty Detection. Also, you can find our pre-trained models and our final results.

ARAE vs DAE Unlike DAE, ARAE that is trained on the normal class, which is the digit 8, reconstructs a normal instance when it is given an anomalous digit, from the class 1.

Running the code

Having cloned the repository, you can reproduce our results:

1. L-inf model:

If you want to use the pre-trained models, skip to this section.

Preparing the data

At first, run prepare.py to prepare the data. The first argument to be passed is the dataset name. You may choose between fashion_mnist, mnist, and coil100. For mnist and fashion_mnist, the next argument is the chosen protocol to prepare the data. For this argument, you may choose between p1 and p2. If p2 is chosen, the next argument is the normal class number. Otherwise, the next argument is the anomaly percentage. Then you have to pass the class number.

Here are two examples for mnist and fashion_mnist datasets:

python3 prepare.py mnist p1 0.5 8
python3 prepare.py fashion_mnist p2 2

For the coil100 dataset, only the first protocol is available. After passing the dataset name, you have to pass the anomaly percentage. Next, you pass the number of normal classes. After that, the class numbers are passed.

Here is an example for the coil100 dataset:

python3 prepare.py coil100 0.25 4 1 3 77 10

Training

To train the model by yourself, you have to run the following script:

python3 train.py

Testing

If you trained the model yourself, you can use the following script to test your model:

python3 test.py

To use the pre-trained models, you have to pass the model directory to test.py. The pre-trained models are available in the pretrained_models folder. For mnist, the model is trained using both protocols, for all classes. For fashion_mnist, the model is trained using the second protocol for all classes. Finally, for coil100, 30 models are trained by varying the number of normal classes between 1, 4, and 7. To test the first protocol for mnist, you have to pass the anomaly percentage as an additional argument.

Here are examples for all the three datasets:

python3 test.py ./pretrained_models/mnist_pretrained/p2/8/
python3 test.py ./pretrained_models/mnist_pretrained/p1/5/ 0.5
python3 test.py ./pretrained_models/fashion_mnist_pretrained/2/
python3 test.py ./pretrained_models/coil100_pretrained/4/30/

2. Union model:

  • At first, you need to complete the submit.sh according to your HPC setting to submit a sbatch file.
  • Then, you just need to run main.sh on the HPC, It will automatically run code.py for 10 classes.
  1. Note that by runnig the code.py you can save models and get results for a given class.
  2. You can separately run code.py by passing a number of class as an argument.

Citation

@misc{salehi2020arae,
    title={ARAE: Adversarially Robust Training of Autoencoders Improves Novelty Detection},
    author={Mohammadreza Salehi and Atrin Arya and Barbod Pajoum and Mohammad Otoofi and Amirreza Shaeiri and Mohammad          Hossein Rohban and Hamid R. Rabiee},
    year={2020},
    eprint={2003.05669},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

salehi_submitted_2020's People

Contributors

abnormaldetection avatar amirrezashaeiri avatar atrin78 avatar otoofim avatar rohban-lab 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.