readme: ## Diffusion-GAN &mdash; Official PyTorch implementation
  
  **Diffusion-GAN: Training GANs with Diffusion**<br>
  Zhendong Wang, Huangjie Zheng, Pengcheng He, Weizhu Chen and Mingyuan Zhou <br>
  https://arxiv.org/abs/2206.02262 <br>
  
  Abstract: *For stable training of generative adversarial networks (GANs), injecting instance
  noise into the input of the discriminator is considered as a theoretically sound
  solution, which, however, has not yet delivered on its promise in practice. This
  paper introduces Diffusion-GAN that employs a Gaussian mixture distribution,
  defined over all the diffusion steps of a forward diffusion chain, to inject instance
  noise. A random sample from the mixture, which is diffused from an observed
  or generated data, is fed as the input to the discriminator. The generator is
  updated by backpropagating its gradient through the forward diffusion chain,
  whose length is adaptively adjusted to control the maximum noise-to-data ratio
  allowed at each training step. Theoretical analysis verifies the soundness of the
  proposed Diffusion-GAN, which provides model- and domain-agnostic differentiable
  augmentation. A rich set of experiments on diverse datasets show that DiffusionGAN can 
  provide stable and data-efficient GAN training, bringing consistent
  performance improvement over strong GAN baselines for synthesizing photorealistic images.*
  
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-celeba-64x64)](https://paperswithcode.com/sota/image-generation-on-celeba-64x64?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-stl-10)](https://paperswithcode.com/sota/image-generation-on-stl-10?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-lsun-bedroom-256-x-256)](https://paperswithcode.com/sota/image-generation-on-lsun-bedroom-256-x-256?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-afhq-wild)](https://paperswithcode.com/sota/image-generation-on-afhq-wild?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-afhq-cat)](https://paperswithcode.com/sota/image-generation-on-afhq-cat?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-afhq-dog)](https://paperswithcode.com/sota/image-generation-on-afhq-dog?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-lsun-churches-256-x-256)](https://paperswithcode.com/sota/image-generation-on-lsun-churches-256-x-256?p=diffusion-gan-training-gans-with-diffusion)
  [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/diffusion-gan-training-gans-with-diffusion/image-generation-on-ffhq-1024-x-1024)](https://paperswithcode.com/sota/image-generation-on-ffhq-1024-x-1024?p=diffusion-gan-training-gans-with-diffusion)
  
  ## ToDos
  - [x] Initial code release
  - [x] Providing pretrained models
  
  ## Build your Diffusion-GAN
  Here, we explain how to train general GANs with diffusion. We provide two ways: 
  a. plug-in as simple as a data augmentation method; 
  b. training GANs on diffusion chains with a timestep-dependent discriminator. 
  Currently, we didn't find significant empirical differences of the two approaches, 
  while the second approach has stronger theoretical guarantees. We suspect when advanced timestep-dependent structure is applied in the discriminator,
  the second approach could become better, and we left that for future study. 
  
  ### Simple Plug-in
  * Design a proper diffusion process based on the ```diffusion.py``` file
  * Apply diffusion on the inputs of discriminators, 
  ```logits = Discriminator(Diffusion(gen/real_images))```
  * Add adaptiveness of diffusion into your training iterations
  ``` 
  if update_diffusion:  # batch_idx % ada_interval == 0
      adjust = np.sign(sign(Discriminator(real_images)) - ada_target) * C  # C = (batch_size * ada_interval) / (ada_kimg * 1000)
      diffusion.p = (diffusion.p + adjust).clip(min=0., max=1.)
      diffusion.update_T()
  ```
  
  ### Full Version
  * Add diffusion timestep `t` as an input for discriminators `logits = Discriminator(images, t)`. 
  You may need some modifications in your discriminator architecture. 
  * The other steps are the same as Simple Plug-in. Note that since discriminator depends on timesteps, 
  you