资源算法pytorch-generative-model-collections

pytorch-generative-model-collections

2019-09-11 | |  196 |   0 |   0

pytorch-generative-model-collections

Original : [Tensorflow version]

Pytorch implementation of various GANs.

This repository was re-implemented with reference to tensorflow-generative-model-collections by Hwalsuk Lee

I tried to implement this repository as much as possible with tensorflow-generative-model-collections, But some models are a little different.

This repository is included code for CPU mode Pytorch, but i did not test. I tested only in GPU mode Pytorch.

Dataset

  • GAN, LSGAN, WGAN, WGAN_GP, DRAGAN, EBGAN, BEGAN used dataset of the torchvision.

  • infoGAN, ACGAN, CGAN used dataset downloaded from MNIST (http://yann.lecun.com/exdb/mnist/) and fashion-MNIST (https://github.com/zalandoresearch/fashion-mnist).

Difference from tensorflow-generative-model-collections

  • This repository does not have Variational Auto-Encoders.

  • DRAGAN : The DRAGAN loss calculation method is different.

  • ACGAN : The learning procedure is different.

  • EBGAN : MSE is used instead of L2 norm and the last layer of discriminator does not use sigmoid activation function.

  • BEGAN : L1 norm is used instead of L2 norm and the last layer of discriminator does not use sigmoid activation function.

Generative Adversarial Networks (GANs)

Lists (Table is borrowed from tensorflow-generative-model-collections)

图片.png

Variants of GAN structure (Figures are borrowed from tensorflow-generative-model-collections)

GAN_structure.png

Results for mnist

Network architecture of generator and discriminator is the exaclty sames as in infoGAN paper.
For fair comparison of core ideas in all gan variants, all implementations for network architecture are kept same except EBGAN and BEGAN. Small modification is made for EBGAN/BEGAN, since those adopt auto-encoder strucutre for discriminator. But I tried to keep the capacity of discirminator.

The following results can be reproduced with command:

python main.py --dataset mnist --gan_type <TYPE> --epoch 25 --batch_size 64

Fixed generation

All results are generated from the fixed noise vector.

Name | Epoch 1 | Epoch 10 | Epoch 25 | GIF :---: | :---: | :---: | :---: | :---: | GAN | GAN_epoch001.png | GAN_epoch025.png | GAN_epoch025.png | GAN_generate_animation.gif LSGAN | LSGAN_epoch001.png | LSGAN_epoch025.png | LSGAN_epoch025.png | LSGAN_generate_animation.gif WGAN | WGAN_epoch001.png | WGAN_epoch025.png | WGAN_epoch025.png | WGAN_generate_animation.gif WGAN_GP | WGAN_GP_epoch001.png | WGAN_GP_epoch025.png | WGAN_GP_epoch025.png | WGAN_GP_generate_animation.gif DRAGAN | DRAGAN_epoch001.png | DRAGAN_epoch025.pngDRAGAN_epoch025.png | DRAGAN_generate_animation.gif EBGAN | EBGAN_epoch001.png | EBGAN_epoch025.png | EBGAN_epoch025.png | EBGAN_generate_animation.gif BEGAN | BEGAN_epoch001.png | BEGAN_epoch025.pngBEGAN_epoch025.png | BEGAN_generate_animation.gif

Conditional generation

Each row has the same noise vector and each column has the same label condition.

Name | Epoch 1 | Epoch 10 | Epoch 25 | GIF :---: | :---: | :---: | :---: | :---: | CGAN | 

InfoGAN : Manipulating two continous codes

All results have the same noise vector and label condition, but have different continous vector.

Name | Epoch 1 | Epoch 10 | Epoch 25 | GIF :---: | :---: | :---: | :---: | :---: | infoGAN | 

Loss plot

Name | Loss :---: | :---: | GAN | 

Results for fashion-mnist

Comments on network architecture in mnist are also applied to here.
Fashion-mnist is a recently proposed dataset consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from 10 classes. (T-shirt/top, Trouser, Pullover, Dress, Coat, Sandal, Shirt, Sneaker, Bag, Ankle boot)

The following results can be reproduced with command:

python main.py --dataset fashion-mnist --gan_type <TYPE> --epoch 25 --batch_size 64

Fixed generation

All results are generated from the fixed noise vector.

Name | Epoch 1 | Epoch 10 | Epoch 25 | GIF :---: | :---: | :---: | :---: | :---: | GAN | GAN_epoch001.png | GAN_epoch025.png | GAN_epoch025.png | GAN_generate_animation.gif LSGAN | WGAN_epoch001.png | WGAN_epoch025.png | WGAN_epoch025.png | WGAN_generate_animation.gif WGAN | LSGAN_epoch001.png | WGAN_epoch025.png | LSGAN_epoch025.png | LSGAN_generate_animation.gif WGAN_GP | WGAN_GP_epoch001.png | WGAN_GP_epoch025.png | WGAN_GP_epoch025.png | WGAN_GP_generate_animation.gif DRAGAN | DRAGAN_epoch001.png | DRAGAN_epoch025.png | DRAGAN_epoch025.png | DRAGAN_generate_animation.gif 

Conditional generation

Each row has the same noise vector and each column has the same label condition.

Name | Epoch 1 | Epoch 10 | Epoch 25 | GIF :---: | :---: | :---: | :---: | :---: | CGAN | CGAN_epoch001.pngCGAN_epoch025.pngACGAN_epoch001.pngACGAN_epoch001.pngACGAN_epoch025.pngACGAN_generate_animation.gifinfoGAN_epoch001.pnginfoGAN_epoch025.pnginfoGAN_generate_animation.gif

  • Without hyper-parameter tuning from mnist-version, infoGAN does not work well as compared with CGAN/ACGAN.

  • ACGAN tends to fall into mode-collapse in tensorflow-generative-model-collections, but Pytorch ACGAN does not fall into mode-collapse.

  • infoGAN tends to ignore noise-vector. It results in that various style within the same class can not be represented.

InfoGAN : Manipulating two continous codes

All results have the same noise vector and label condition, but have different continous vector.

Name | Epoch 1 | Epoch 10 | Epoch 25 | GIF :---: | :---: | :---: | :---: | :---: | infoGAN | 图片.png

Loss plot

Name | Loss :---: | :---: | GAN | 

图片.png

图片.png

图片.png



Folder structure

The following shows basic folder structure.

├── main.py # gateway
├── data
│   ├── mnist # mnist data (not included in this repo)
│   ├── ...
│   ├── ...
│   └── fashion-mnist # fashion-mnist data (not included in this repo)
│
├── GAN.py # vainilla GAN
├── utils.py # utils
├── dataloader.py # dataloader
├── models # model files to be saved here
└── results # generation results to be saved here

Development Environment

  • Ubuntu 14.04 LTS

  • NVIDIA GTX 1080 ti

  • cuda 8.0

  • Python 2.7.6

  • pytorch 0.2.0+5585c26

  • torchvision 0.1.9

  • numpy 1.13.1

  • matplotlib 1.3.1

  • imageio 2.2.0

  • scipy 0.19.1

Acknowledgements

This implementation has been based on tensorflow-generative-model-collections and tested with Pytorch on Ubuntu 14.04 using GPU.

上一篇:SqueezeNet

下一篇:pygcn

用户评价
全部评价

热门资源

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...