Previous sections explored stabilizing GAN training by modifying the loss function's underlying distance metric (like in WGANs) or by applying regularization techniques (like Spectral Normalization). Relativistic GANs offer a different perspective on improving stability by fundamentally changing what the discriminator is asked to predict.
In a standard GAN formulation, the discriminator D tries to estimate the absolute probability that a given input x is real. Its output D(x) is often interpreted as P(x is real). The generator G is then trained to produce samples G(z) that maximize this probability D(G(z)).
Relativistic GANs propose that it might be more effective and stable for the discriminator to predict the relative probability that given real data is more realistic than fake data, sampled randomly. Instead of outputting an absolute score, the discriminator's task becomes comparative.
Let C(x) represent the output of the discriminator before the final activation function (e.g., sigmoid). In a standard GAN (SGAN), the discriminator loss involves terms like log(σ(C(xreal))) and log(1−σ(C(xfake))), where σ is the sigmoid function.
A particularly effective variant is the Relativistic average GAN (RaGAN). Instead of comparing a single real sample to a single fake sample, RaGAN compares a sample (real or fake) against the average assessment of samples from the opposing distribution.
The core idea is formalized in the RaSGAN (Relativistic average Standard GAN) loss functions. The discriminator D is trained to maximize:
LDRaSGAN=−Exreal∼Preal[log(σreal)]−Exfake∼Pfake[log(1−σfake)]where:
Here, Exfake∼Pfake[C(xfake)] is the average discriminator output for fake samples in the batch, and Exreal∼Preal[C(xreal)] is the average discriminator output for real samples in the batch. The discriminator is learning to make C(xreal) larger than the average C(xfake), and C(xfake) smaller than the average C(xreal).
The generator G is trained to minimize the opposite objective:
LGRaSGAN=−Exfake∼Pfake[log(σfake)]−Exreal∼Preal[log(1−σreal)]Notice the symmetry. The generator benefits both from increasing the perceived realism of its generated samples relative to the average real sample (σfake) and decreasing the perceived realism of real samples relative to the average fake sample (1−σreal). This structure provides gradients to the generator based on both real and fake samples, which can lead to more stable learning.
Implementing RaGAN involves modifying the loss calculation:
Relativistic GANs, particularly RaGAN, provide a different approach to GAN training. By shifting the discriminator's task from absolute to relative realism assessment, they offer a practical method for achieving more stable and effective training, adding another valuable technique to your toolkit for building advanced generative models. While techniques like WGAN-GP or Spectral Normalization address stability through distance metrics or regularization, RaGAN modifies the fundamental objective of the discriminator-generator game itself.
© 2025 ApX Machine Learning