GithubHelp home page GithubHelp logo

expvae's Introduction

ExpVAE

Overview

This repository provides training and testing code and data for CVPR 2020 paper:

"Towards Visually Explaining Variational Autoencoders", Wenqian Liu, Runze Li, Meng Zheng, Srikrishna Karanam, Ziyan Wu, Bir Bhanu, Richard J. Radke, and Octavia Camps

Further information please contact Wenqian Liu at [email protected], Runze Li at [email protected] .

Requirements

Running codes

  • Start trainning a one-class VAE with default settings by call:
python train_expVAE.py 

other options are:

[-h] [--result_dir DIR] [--ckpt_dir DIR] [--batch_size N] [--epochs N] 
     [--seed S] [--resume PATH] [--latent_size N] [--one_class N]

Here result_dir saves validating visualizations; ckpt_dir saves best model after each epoch; latent_size decides VAE's latent vector shape; one_class decides which digit to be used as inlier to train on.

  • Start testing with default settings by call:
python test_expVAE.py

other options are:

[-h] [--result_dir DIR] [--batch_size N] [--seed S]
     [--latent_size N] [--model_path DIR] [--one_class N]

Here one_class decides the outlier digit, so that expVAE will generate anomaly localization attention maps, in which high response regions denote the difference between the outlier digit and the inlier digit.

Pretrained models for MNIST can be found here

License and Citation

The use of this software is RESTRICTED to non-commercial research and educational purposes.

@article{liu2019towards,
  title={Towards Visually Explaining Variational Autoencoders},
  author={Liu, Wenqian and Li, Runze and Zheng, Meng and Karanam, Srikrishna and Wu, Ziyan and Bhanu, Bir and Radke, Richard J and Camps, Octavia},
  journal={arXiv preprint arXiv:1911.07389},
  year={2019}
}

expvae's People

Stargazers

He Jiabei avatar  avatar  avatar Xiaoyang Song avatar Hung Nguyen avatar  avatar Yuning Wang avatar  avatar bio avatar fridayfang avatar  avatar  avatar Sinie avatar HoTaek Joo avatar  avatar  avatar Hoàng Xuân Trường avatar anand avatar Aiden avatar yue wu avatar Shizuko Morimoto avatar  avatar Li Zhaoxu avatar Takuya Wakisaka avatar livic avatar  avatar Keun avatar Samuel Zhou avatar yunseung-lee avatar haifeng xia avatar  avatar 风马訾垚 avatar BOSHU LEI avatar JoseV avatar rayna avatar Akira Kinose avatar  avatar Bongjun Kim avatar  avatar Marijan Smetko avatar Shivam Kaushik avatar jkang avatar Nguyen Thanh Phuong avatar  avatar DKzz avatar  avatar Frank Brongers avatar Huaiyu Zheng avatar Weijian Li avatar Siyuan Lu avatar Jiaqi Wang avatar  avatar Subin An avatar Kwon Ko avatar Qinghua Zhou avatar JieYang avatar Xi Ouyang avatar Jun-Wei, Liu avatar Meng Zheng avatar Wang Bomin avatar  avatar

Watchers

JieYang avatar  avatar Siyuan Lu avatar paper2code - bot avatar

expvae's Issues

test can't run

I run:
python test_expVAE.py
And get error as follows:

cuda available
Traceback (most recent call last):
  File "test_expVAE.py", line 99, in <module>
    main()
  File "test_expVAE.py", line 77, in main
    gcam.backward(mu, logvar, mu_avg, logvar_avg)
  File "/mnt/data/home/x/expVAE/code/gradcam.py", line 60, in backward
    self.score_fc.backward(gradient=one_hot, retain_graph=True)
  File "/mnt/data/home/x/anaconda3/envs/py38pytorch151/lib/python3.8/site-packages/torch/tensor.py", line 195, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/mnt/data/home/x/anaconda3/envs/py38pytorch151/lib/python3.8/site-packages/torch/autograd/__init__.py", line 93, in backward
    grad_tensors = _make_grads(tensors, grad_tensors)
  File "/mnt/data/home/x/anaconda3/envs/py38pytorch151/lib/python3.8/site-packages/torch/autograd/__init__.py", line 25, in _make_grads
    raise RuntimeError("Mismatch in shape: grad_output["
RuntimeError: Mismatch in shape: grad_output[0] has a shape of torch.Size([128, 32]) and output[0] has a shape of torch.Size([]).

A question about 'encode_one_hot_batch' function on gradcam.py

I'm the one who wanted to use this model with different datasets.
However, I'm having trouble getting an anomaly attention map, so I want to ask for advice.

I have a question about the function in gradcam.py python file.
Like below, the function 'encode_one_hot_bath' just return mu, not using one_hot_batch.
Is this configured as intended? or not developed yet?

set the target class as one others as zero. use this vector for back prop added by Lezi
def encode_one_hot_batch(self, z, mu, logvar, mu_avg, logvar_avg):
--one_hot_batch = torch.FloatTensor(z.size()).zero_()
--return mu

Plus, if this function is implemented as intended, I want to ask which part of the code conducted the (4) equation of the paper which generating anomaly attention.

Thanks,

I have some question.

Hello sir.
I have interesting about XAI and VAE.
so i am happy to find your site.

I tested your code.
But i found strange results that i couldn't understand.

When inference your code,
If digit 3, the red area should not appear, i think.
But the red area did appear.
How do you think about it?

If you agree my opinion, how can modify your code?
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.