Git Product home page Git Product logo

f-anogan-pytorch's Introduction

f-AnoGAN-PyTorch

An unofficial implementation of f-AnoGAN in PyTorch.

Reference

Dataset

This implementation performs anomaly detection on CIFAR-10. In the common setting we treat one class of CIFAR-10 as normal class and other 9 classes as anomalies. You can specify which class is considered as normal when running fanogan.py in command line by setting the --class argument.

Usage

  • Train a GAN

      python fanogan.py --stage 1 --class NORMAL_CLASS
    
  • Train an encoder

      python fanogan.py --stage 2 --class NORMAL_CLASS
    
  • Evaluation

      python fanogan.py --eval --class NORMAL_CLASS
    

f-anogan-pytorch's People

Contributors

dbbbbm avatar

Stargazers

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

Watchers

 avatar  avatar

f-anogan-pytorch's Issues

Encoder Tanh

Hello,

I believe there is an error in the encoder architecture?
The last layer of the encoder uses Tanh, which does not make sense to me since the generator input is torch.randn(64, 128), which can output values below -1 and above 1.
The tanh activation is limiting the encoder output to -1 and 1 though.
This might explain why the images generated in the izif training aren't that good.

Am I missing something?

Mean Squared Error in Evaluation

Hello, first of all thanks for this awesome implementation.

I'm looking at the file fanogan.py in line 247 to 252. Here's the code:

f_x, f_gx = netD.extract_feature(d_input).chunk(2, 0)
rec_diff = ((rec_image.view(bs, -1) - x.view(bs, -1))**2)
rec_score = rec_diff.mean(dim=1) - rec_diff.std(dim=1)
feat_diff = ((f_x - f_gx)**2)
feat_score = feat_diff.mean(dim=1) + feat_diff.std(dim=1)
outlier_score = rec_score + options.alpha * feat_score

This looks like the mean squared error to me, which makes sense since that is used in the paper.
However, I don't really understand why you subtract the standard deviation from the mean error.
Also, the deviation is added to the mean error of extracted features.
I've tested this and i've seen that the tensor rec_score holds negative values, which would not be possible with the mean squared error as it is implemented in for example sklearn.metrics. However, using the standard deviation raises my ROC score from 0.91 to 0.93. Could you give me a hint why the deviation is included at all?

About CRITIC_ITERS

Thanks for your code, but I don't understand what's the function of the CRITIC_ITER. It seems that only the first 5 batches datas (CRITIC_ITER=5) are used for training. Could you please help explain it? Thank you.

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.