Coder Social home page Coder Social logo

lvat's Introduction

LVAT

The code used in the evaluation of Latent Space Virtual Adversarial Training (ECCV 2020 Oral).

Reference

This code is written based on the original VAT implementation (see here),
and the implementation for Glow is heavily based on this code.

Requirements

tensorflow-gpu 1.14

Preparation 1. Create symbolic links

cd lvat/
# for LVAT-VAE
ln -s ../vae/VAE.py .
ln -s ../vae/config.py .
ln -s ../vae/util .
ln -s ../vae/out_VAE_SVHN/ out_VAE_SVHN
ln -s ../vae/out_VAE_SVHN_aug/ out_VAE_SVHN_aug
ln -s ../vae/out_VAE_CIFAR10/ out_VAE_CIFAR10
ln -s ../vae/out_VAE_CIFAR10_aug/ out_VAE_CIFAR10_aug

# for LVAT-Glow
ln -s ../glow/out/SVHN/w_128__step_22__scale_3__b_128/ out_Glow_SVHN
ln -s ../glow/out/SVHN_aug/w_128__step_22__scale_3__b_128/ out_Glow_SVHN_aug
ln -s ../glow/out/CIFAR10/w_128__step_22__scale_3__b_128/ out_Glow_CIFAR10
ln -s ../glow/out/CIFAR10_aug/w_128__step_22__scale_3__b_128/ out_Glow_CIFAR10_aug

Preparation 2. Create tfrecords

cd vae/util/

and

python svhn.py --data_dir=<YOUR_PATH>

or

python cifar10.py --data_dir=<YOUR_PATH>

Preparation 3. Building transfomer(VAE/Glow)

For VAE,

cd vae
python build_AE.py

and for Glow,

cd glow
python main.py

For both, target datasets are identified in config.py (for VAE) or config_glow.py (for Glow). For VAE, you have to change the directory name where the trained model will be saved so as to accord to the one referred to by the symbolic links created in Preparation 1. For Glow, the trained model can be referred as it is.

Training Classifier with LVAT

cd lvat

and for example

python train_semisup.py --data_set=SVHN --num_epochs=200
--epoch_decay_start=80 --epsilon=1.5 --top_bn --method=lvat --log__dir=./out
--data__dir=<YOUR_PATH> --num_iter_per_epoch=400
--batch_size=32 --ul_batch_size=128 --num_labeled_examples=1000
--is_aug=True --ae_type=Glow

Description

  • --data_set can choose from either SVHN or CIFAR10.
  • <YOUR_PATH> that will be given as --data__dir should be the same as the one you identified in the above Preparation 2.
  • --log__dir is the directory name where the check-point file will be saved.
  • --epsilon is the magnitude of perturbation, which is commonly used for both --method=lvat and --method=vat.
  • If you set --metod=vat, then it works as the original vat.
  • You can choose the transfomer from VAE and Glow by --ae_type=VAE and --ae_type=Glow, respectively.

Important

For SVHN, --top_bn option is necessary to achieve good results.

lvat's People

Contributors

geosada avatar

Stargazers

 avatar Taco avatar Yongkang Chen avatar 云销雨霁 avatar Desheng Wang avatar Takashi Shirakawa avatar  avatar  avatar Xiaopeng Guo avatar WANG XIN avatar Brown Chen avatar  avatar  avatar luckiepeng avatar Hsin-Ping Chou avatar  avatar Zhun Zhong avatar

Watchers

 avatar

lvat's Issues

Why Lvat can inject larger perturbation than vat?

Hi, Lvat is a nice work which improved the vat.

But I still feel confused about the reason that lvat can use larger perturbation in the latent space. The way to compute perturbation is the same for both vat and lvat.

Is it an experimental conclusion? Or I have missed some theoretical analysis?

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.