Abstract
Standard Generative Adversarial Networks (GANs) typically map a fixed, simple noise distribution to a complex data manifold, placing a significant modeling burden on the generator network. We introduce Generator Reversal, a technique that employs gradient descent to infer the latent codes of real data. By utilizing these inferred codes to construct a flexible, non-parametric prior via Kernel Density Estimation (KDE), we allow the model to adapt its latent structure to the data. This approach reduces the generator's workload, resulting in faster training, superior sample quality, and enhanced robustness against mode collapse.
Introduction
In the current landscape of deep generative modeling, it is standard practice to sample latent codes from a simple, fixed prior, such as an isotropic Gaussian ($\mathcal{N}(0, \mathbf{I})$). The generator is then expected to perform the complex task of warping this uniform "blob" of noise into the intricate, multi-modal distributions characteristic of natural data like images or speech.
This mismatch between a simplistic prior and complex target data forces the generator to learn highly non-linear and clustered mappings. Such requirements often lead to training instabilities, vanishing gradients, and the well-known issue of mode collapse. We propose that increasing the modeling power of the generative system can be achieved more effectively by allowing the prior distribution to be structured and flexible, rather than merely increasing the depth or width of the generator network.
Methodology: Generator Reversal
To implement a flexible prior, we must characterize the latent space corresponding to real data. Unlike Variational Autoencoders (VAEs) or BiGANs, which train an auxiliary encoder, we utilize the existing generator through a process called Generator Reversal.
Gradient-Based Reversal
For any given real image $x$, we initialize a random latent code $z$ and optimize it using gradient descent to minimize the reconstruction error between the generator's output $G(z)$ and the target $x$. This process effectively "reverses" the generator to find the latent representation of real-world samples.
Flexible Priors via KDE
Once a batch of reversed latent codes is obtained, we apply Kernel Density Estimation (KDE) to estimate a non-parametric probability density function. During subsequent GAN training, we sample from this structured KDE prior instead of the standard Gaussian. This allows the generator to start from a latent distribution that already reflects the multi-modal nature of the data.
MMD Stopping Criterion
To mitigate the computational cost of gradient-based optimization at every training step, we employ a Maximum Mean Discrepancy (MMD) stopping criterion. The reversal process terminates once the MMD test can no longer distinguish between the reconstructed latent codes of real data and those of generated data. This dynamically adjusts the computational effort, requiring more precision only as the generator improves.
Key Insights
A central observation of this work is that latent spaces are naturally "clumpy." When projecting reversed latent codes into a lower-dimensional space using t-SNE, they organize into distinct clusters corresponding to data classes (e.g., digit types in MNIST). Forcing a generator to map a smooth Gaussian onto these discrete clusters creates an unnecessary bottleneck.
Furthermore, we discovered that even untrained generators with random weights are surprisingly reversible. Within a few gradient steps, a random network can produce recognizable outlines of target images, suggesting that the architectural priors of convolutional networks are well-suited for this task.
Experimental Results
We evaluated our approach on standard benchmarks including MNIST, SVHN, CIFAR10, and CelebA.
- Convergence and Quality: The KDE-based GAN achieved higher Inception Scores significantly faster than vanilla DCGAN architectures. Samples produced early in training exhibited noticeably higher fidelity and sharpness.
- Mode Collapse Recovery: Using a custom "MNIST1000" dataset designed to simulate extreme mode dropping, the Generator Reversal model successfully recovered missing modes. It achieved an Inception Score of 289, vastly outperforming vanilla GANs (196) and BiGANs (200).
- Generalization: Evaluations using nearest-neighbor tests and manifold traversals confirmed that the KDE prior does not lead to memorization. The model maintains smooth interpolations, indicating a semantically meaningful and continuous latent space.
Discussion and Future Work
The primary trade-off for the improved performance of Generator Reversal is computational overhead. Depending on the required reversal steps, training iterations can be 1.9x to 9.8x slower than standard GANs. Future work will focus on optimizing the inner optimization loop and exploring the KDE kernel bandwidth as a control parameter for the balance between data memorization and generalization.
Summary updated