All Projects → IShengFang → Relativistic Average Gan Keras

IShengFang / Relativistic Average Gan Keras

The implementation of Relativistic average GAN with Keras

Projects that are alternatives of or similar to Relativistic Average Gan Keras

Spectralnormalizationkeras
Spectral Normalization for Keras Dense and Convolution Layers
Stars: ✭ 100 (+177.78%)
Mutual labels:  jupyter-notebook, gan, deeplearning, generative-adversarial-network, cifar10
Generative adversarial networks 101
Keras implementations of Generative Adversarial Networks. GANs, DCGAN, CGAN, CCGAN, WGAN and LSGAN models with MNIST and CIFAR-10 datasets.
Stars: ✭ 138 (+283.33%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network, mnist, cifar10
Deep Learning Resources
由淺入深的深度學習資源 Collection of deep learning materials for everyone
Stars: ✭ 422 (+1072.22%)
Mutual labels:  jupyter-notebook, gan, deeplearning, generative-adversarial-network
Pytorch Tutorials Examples And Books
PyTorch1.x tutorials, examples and some books I found 【不定期更新】整理的PyTorch 1.x 最新版教程、例子和书籍
Stars: ✭ 346 (+861.11%)
Mutual labels:  jupyter-notebook, deeplearning, deep-learning-tutorial
MNIST-invert-color
Invert the color of MNIST images with PyTorch
Stars: ✭ 13 (-63.89%)
Mutual labels:  generative-adversarial-network, gan, mnist
Faceswap Gan
A denoising autoencoder + adversarial losses and attention mechanisms for face swapping.
Stars: ✭ 3,099 (+8508.33%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
Sdv
Synthetic Data Generation for tabular, relational and time series data.
Stars: ✭ 360 (+900%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
Pytorch Mnist Celeba Gan Dcgan
Pytorch implementation of Generative Adversarial Networks (GAN) and Deep Convolutional Generative Adversarial Networks (DCGAN) for MNIST and CelebA datasets
Stars: ✭ 363 (+908.33%)
Mutual labels:  gan, generative-adversarial-network, mnist
Simgan Captcha
Solve captcha without manually labeling a training set
Stars: ✭ 405 (+1025%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
Generative Adversarial Networks
Introduction to generative adversarial networks, with code to accompany the O'Reilly tutorial on GANs
Stars: ✭ 505 (+1302.78%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
Androidtensorflowmnistexample
Android TensorFlow MachineLearning MNIST Example (Building Model with TensorFlow for Android)
Stars: ✭ 449 (+1147.22%)
Mutual labels:  deeplearning, mnist, deep-learning-tutorial
Hidt
Official repository for the paper "High-Resolution Daytime Translation Without Domain Labels" (CVPR2020, Oral)
Stars: ✭ 513 (+1325%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
gans-2.0
Generative Adversarial Networks in TensorFlow 2.0
Stars: ✭ 76 (+111.11%)
Mutual labels:  generative-adversarial-network, mnist, cifar10
Nn
🧑‍🏫 50! Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠
Stars: ✭ 5,720 (+15788.89%)
Mutual labels:  jupyter-notebook, gan, deep-learning-tutorial
T81 558 deep learning
Washington University (in St. Louis) Course T81-558: Applications of Deep Neural Networks
Stars: ✭ 4,152 (+11433.33%)
Mutual labels:  jupyter-notebook, gan, deeplearning
Gan Tutorial
Simple Implementation of many GAN models with PyTorch.
Stars: ✭ 227 (+530.56%)
Mutual labels:  jupyter-notebook, gan, mnist
Tf Vqvae
Tensorflow Implementation of the paper [Neural Discrete Representation Learning](https://arxiv.org/abs/1711.00937) (VQ-VAE).
Stars: ✭ 226 (+527.78%)
Mutual labels:  jupyter-notebook, mnist, cifar10
Fewshot Face Translation Gan
Generative adversarial networks integrating modules from FUNIT and SPADE for face-swapping.
Stars: ✭ 705 (+1858.33%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
Dragan
A stable algorithm for GAN training
Stars: ✭ 189 (+425%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network
Gan steerability
On the "steerability" of generative adversarial networks
Stars: ✭ 225 (+525%)
Mutual labels:  jupyter-notebook, gan, generative-adversarial-network

Relativistic average GAN with Keras

The implementation Relativistic average GAN with Keras

[paper] [blog] [original code(pytorch)]

How to Run?

Python3 Script

mkdir result
python RaGAN_CustomLoss.py --dataset [dataset] --loss [loss] 
python RaGAN_CustomLayers.py --dataset [dataset] --loss [loss] 

[dataset]: mnist, fashion_mnist, cifar10

[loss]: BXE for Binary Crossentropy, LS for Least Squares

italic arguments are default

Jupyter notebook

Custom Loss [Colab][NBViewer]

Custom Layer [Colab][NBViewer]

Result

1 epoch MNIST Fashion MNIST CIFAR10
Binary Cross Entropy
Least Square
10 epoch MNIST Fashion MNIST CIFAR10
Binary Cross Entropy
Least Square
50epoch MNIST Fashion MNIST CIFAR10
Binary Cross Entropy
Least Square
100epoch MNIST Fashion MNIST CIFAR10
Binary Cross Entropy
Least Square
Loss MNIST Fashion MNIST CIFAR10
Binary Cross Entropy
Least Square

What is Relativistic average GAN?

TL;DR

What is different with original GAN

For better math equations rendering, check out HackMD Version

GAN

The GAN is the two player game which subject as below

formula

formula is a value function( aka loss or cost function) formula is a generator, formula is a sample noise from the distribution we known(usually multidimensional Gaussian distribution). formula is a fake data generated by the generator. We want formula in the real data distribution. formula is a discriminator, which finds out that formula is a real data (output 1) or a fake data(output 0) In the training iteration, we will train one neural network first(usual is discriminator), and train the other network. After a lot of iterations, we expect the last generator to map multidimensional Gaussian distribution to the real data distribution.

Relativistic average GAN (RaGAN)

RaGAN's Loss function does not optimize discriminator to distinguish data real or fake. Instead, RaGAN's discriminator distinguishes that "real data isn’t like average fake data" or "fake data isn’t like average real data".

the discriminator estimates the probability that the given real data is more realistic than a randomly sampled fake data. paper subsection.4.1

Given Discriminator output formula Origin GAN Loss is as below,

formula])

formula

Relativistic average output is formula and formula

RaGAN's Loss is as below, formula formula

we can also add relativistic average in Least Square GAN or any other GAN Modified by Jonathan Hui from Paper

How to implement with Keras?

We got loss, so just code it. 😄 Just kidding, we have two approaches to implement RaGAN. The important part of implementation is discriminator output. formula and formula We need to average formula and formula. We also need "minus" to get formula and formula.

We can use keras.backend to deal with it, but that means we need to custom loss. We can also write custom layers to apply these computations to keras as a layer, and use Keras default loss to train the model.

  1. Custom layer

    • Pros:
      • Train our RaGAN easily with keras default loss
    • Cons:
      • Write custom layers to implement it.
    • [Colab][NBViewer]
  2. Custom Loss

    • Pros:
      • Do not need to write custom layers. Instead, we need write loss with keras.backend.
      • Custom loss is easy to change loss.
    • Cons:
      • Write custom loss with keras.backend to implement it.
    • [Colab][NBViewer]

Code

Custom Loss

[Colab][NBViewer][python script]

Custom Layer

[Colab][NBViewer][python script]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].