Skip to content

Some demo GAN models implemented with pytorch, including GAN, WGAN, WGAN-GP, CGAN.

Notifications You must be signed in to change notification settings

wenhaofang/GANDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GAN Demo

This repository includes some demo GAN models.

Note: The project refers to YixinChen-AI and eriklindernoren

Datasets:

Models:

  • model1: GAN

  • model2: WGAN

  • model3: WGAN-GP

  • model4: CGAN

Unit Test

  • for loaders
# MNIST
PYTHONPATH=. python loaders/loader1.py
  • for modules
# GAN
PYTHONPATH=. python modules/module1.py
# WGAN
PYTHONPATH=. python modules/module2.py
# WGAN-GP
PYTHONPATH=. python modules/module3.py
# CGAN
PYTHONPATH=. python modules/module4.py

Main Process

python main.py

You can change the config either in the command line or in the file utils/parser.py

Here are the examples for each module:

# module1
python main.py \
    --name 1 \
    --module 1
# module2
python main.py \
    --name 2 \
    --module 2
# module3
python main.py \
    --name 3 \
    --module 3
# module4
python main.py \
    --name 4 \
    --module 4

Note (重点、难点、疑点、TODO、...)

1、WGAN 和 GAN 的区别

  • Discriminator 去掉最后一层 Sigmoid
  • Optimizer 不使用基于动量的算法,推荐使用 RMSProp、SGD
  • Optimizer 更新参数后,将 Discriminator 的参数截断为固定常数的绝对值
  • Criterion 计算 loss 不取 log

2、WGAN-GP 和 WGAN 的区别

  • 将参数截断替换为梯度惩罚

3、关于 CGAN

  • 对于 Discriminator,输入图片加标签,判断是否为真实图片 (二分类)
  • 对于 Discriminator,判断:真图片加真标签 (1),假图片加假标签 (0)

About

Some demo GAN models implemented with pytorch, including GAN, WGAN, WGAN-GP, CGAN.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages