W-GANDeep learning has undergone a revolution thanks to Generative Adversarial Networks (GANs), which make it possible to produce realistic synthetic data. Even while conventional GANs have been incredibly successful, they can generate low-quality samples and experience instability during training. Wasserstein Generative Adversarial Networks (WGANs) were offered as a solution to these problems. Compared to conventional GANs, WGANs have a number of benefits, including increased sample quality, better training dynamics, and increased stability. The basis of Wasserstein Generative Adversarial Networks is the Wasserstein distance between probability distributions, often referred to as Earth-Mover's distance. WGANs maximize the Wasserstein distance as opposed to conventional GANs, which quantify the difference between distributions using the Jensen-Shannon or Kullback-Leibler divergences. In addition to producing more stable training dynamics, the Wasserstein distance offers a more significant way to quantify distribution dissimilarity. Components of W-GAN
Now for the implementation part, we will implement the W-GAN with Gradient Penalty for MNIST Augmentation. Code: Importing LibrariesUtilitiesNow we will provide the utilities that are required. Now we will create a function that will help in the preparation of data for model training. Building the ModelBy using the Wasserstein distance, the original Wasserstein GAN generates a value function with superior theoretical qualities compared to the value function employed in the initial GAN publication. The discriminator, also known as the critic, must lie inside the space of 1-Lipschitz functions in order for WGAN to work. The authors suggested using weight clipping to accomplish this limitation. Even while weight clipping is effective, it can lead to unwanted behavior and be a troublesome technique to impose the 1-Lipschitz constraint. For example, a very deep WGAN discriminator (critic) frequently fails to converge. Weight clipping is not the only solution suggested by the WGAN-GP approach to guarantee seamless training. The authors suggested a "gradient penalty" in place of trimming the weights, which involves adding a loss term to maintain the discriminator gradients' L2 norm around 1. GeneratorWe first input random noise into the generator and then shape it into the MNIST picture format. The general procedures are as follows:
It's important to note that batch normalization is applied to all layers but the final deconvolution layer. Using selu as the activation for the intermediate deconvolution and tanh for the output is great practice. DiscriminatorThe discriminator will lower the dimensionality of the input pictures by using strided convolutions. LeakyRELU activates these as best practices. Without any activation, the output features will be flattened and sent to a 1-unit dense layer. Output: W-GAN in ActionLet?s now see the W-GAN, when being put to use. Output: Image GeneratedLet us have a look at the images that are generated by the W-GAN model. Output: EvaluationNow, we will use Frechet Distance to represent the evaluation of some generated data samples compared to real data. Frechet Distance is a measure of similarity between two curves or shapes. Output: Here is what we can interpret from the above output:
At 11.02, the fourth score is substantially lower than the prior ones. This implies that the fourth set's produced sample distribution closely resembles the distribution of actual data. Next TopicGreedy Layer Wise Pre-Training |