When Relation Networks meet GANs: Relation GANs with Triplet Loss

Runmin Wu, Kunyao Zhang, Lijun Wang, Yue Wang, Huchuan Lu, Yizhou YuarXiv 2020

Generative Adversarial Networks (GANs) have revolutionized deep learning by enabling the generation of high-fidelity synthetic data. However, they are notoriously difficult to train due to the instability of the adversarial game. The core issue often resides in the Discriminator. In a standard GAN, the discriminator acts as a binary judge, evaluating one image at a time to determine if it is "Real" or "Fake." If the generated distribution is significantly different from the real one, the discriminator becomes too accurate too quickly, leading to vanishing gradients that stall the Generator's progress.

RelationGAN proposes a structural shift: instead of asking "Is this image real?", it asks "Are these two images from the same distribution?" By reimagining the discriminator as a Relation Network, the authors introduce a stable, principled framework for bridging the gap between real and synthetic data.

The Challenge of Training Instability

The primary obstacle in GAN research is the lack of overlap between the supports of the real and generated distributions in high-dimensional space. When these distributions are disjoint, a standard discriminator can easily find a perfect separating hyperplane. Once this occurs, the gradients provided to the generator vanish.

While existing solutions like WGAN-GP or Spectral Normalization attempt to mitigate this by constraining the discriminator's Lipschitz constant, these methods are often empirical and can limit the model's capacity to learn complex features. RelationGAN addresses this at a structural level by changing the fundamental learning objective of the discriminator.

Methodology: The Relation Discriminator

The authors introduce two major innovations to the GAN architecture:

  1. The Relation Discriminator: Instead of processing a single image $x$, the discriminator $D(x_1, x_2)$ evaluates a pair of samples. It consists of an Embedding Module (EM) that projects images into a high-dimensional feature space and a Relation Module (RM) that compares these features to output a "relation score."
    • Symmetric Pairs: (Real, Real) or (Fake, Fake) should yield high similarity scores.
  2. Asymmetric Pairs: (Real, Fake) should yield low similarity scores.
  3. Triplet Loss with Dynamic Margin: Inspired by metric learning in face recognition, a triplet loss is used to force the discriminator to separate symmetric and asymmetric pairs. A distance-based metric ($\Delta$) replaces the standard fixed "margin," allowing for greater flexibility; the model does not over-penalize samples that are already inherently similar.
Overview of the RelationGAN architecture and the adversarial objectives for the Discriminator (D) and Generator (G).

By comparing pairs, the discriminator learns the underlying structure of the distribution rather than memorizing specific pixel patterns. This relational approach effectively "blurs" the boundaries of disjoint distributions in the feature space, providing smoother gradients for the generator.

Experimental Results

RelationGAN was evaluated across various tasks, from synthetic 2D data to high-resolution image generation.

Synthetic 2D Data and Convergence

On synthetic benchmarks like the 8-Gaussian and Swissroll distributions, RelationGAN demonstrated rapid convergence and excellent mode coverage. The authors provided mathematical proof that RelationGAN is locally convergent even without the heavy-handed regularizations required by other GAN variants.

Visualization of the model's ability to capture complex distributions on synthetic 2D data benchmarks.

Mode Coverage and Image Quality

The relational approach is naturally resistant to mode collapse. Because the generator is incentivized to make "Fake-Fake" pairs as similar as "Real-Real" pairs, it must cover the entire breadth of the target distribution.

  • Stacked MNIST: On this benchmark designed to detect mode collapse, RelationGAN captured all 1,000 modes ($1000 \pm 0$), significantly outperforming WGAN-GP (643 modes) and Vanilla GAN (923 modes).
  • CIFAR-10: RelationGAN achieved an FID score of 13.52, a substantial improvement over Vanilla GAN (26.46) and WGAN-GP (63.56).
  • Super-Resolution: Applied to image upscaling on VOC2012, RelationGAN outperformed the SRGAN baseline in both PSNR and SSIM across multiple benchmarks (Set5, Set14, Urban100).

Conclusion and Future Directions

RelationGAN offers a compelling alternative to standard GAN training by leveraging relational learning and triplet loss. While it introduces some computational overhead due to pair processing and is sensitive to the architecture of the Embedding Module, its ability to stabilize training and prevent mode collapse is a significant step forward. Future work may involve scaling this relational approach to ultra-high-resolution datasets ($1024 \times 1024$) to further test its robustness in large-scale generative tasks.

Summary updated

BibTeX
@misc{wu2020when,
  author = {Runmin Wu and Kunyao Zhang and Lijun Wang and Yue Wang and Huchuan Lu and Yizhou Yu},
  title = {{When Relation Networks meet GANs: Relation GANs with Triplet Loss}},
  year = {2020},
  eprint = {2002.10174},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.10174},
}
Figure