Metric Learning-based Generative Adversarial Network

Zi-Yi DouarXiv 2017

Abstract

Generative Adversarial Networks (GANs), as a framework for estimating generative models via an adversarial process, have attracted huge attention and have proven to be powerful in a variety of tasks. However, training GANs is well known for being delicate and unstable, partially caused by its sigmoid cross entropy loss function for the discriminator. To overcome such a problem, many researchers directed their attention on various ways to measure how close the model distribution and real distribution are and have applied different metrics as their objective functions. In this paper, we propose a novel framework to train GANs based on distance metric learning and we call it Metric Learning-based Generative Adversarial Network (MLGAN). The discriminator of MLGANs can dynamically learn an appropriate metric, rather than a static one, to measure the distance between generated samples and real samples. Afterwards, MLGANs update the generator under the newly learned metric. We evaluate our approach on several representative datasets and the experimental results demonstrate that MLGANs can achieve superior performance compared with several existing state-of-the-art approaches. We also empirically show that MLGANs could increase the stability of training GANs.

Introduction

Generative Adversarial Networks (GANs) are renowned for their ability to synthesize high-fidelity images but are notoriously difficult to train. The standard GAN formulation employs a discriminator to distinguish between real and synthetic data using a sigmoid cross-entropy loss. This approach frequently encounters two critical failure modes: vanishing gradients, where a superior discriminator provides no useful signal to the generator, and mode collapse, where the generator produces a limited variety of outputs.

To address these issues, we introduce the Metric Learning-based Generative Adversarial Network (MLGAN). MLGAN redefines the adversarial component by replacing the binary classifier discriminator with a dynamic distance metric learning framework. Instead of simple classification, the discriminator learns a feature space where real and fake samples are separated by distance, providing a richer and more stable gradient signal for the generator.

Methodology

The core innovation of MLGAN lies in transitioning the discriminator from a classifier to an embedding function.

From Classifier to Embedding

In a standard GAN, the discriminator outputs a scalar probability. In MLGAN, the discriminator $D(x)$ maps inputs into a vector embedding space. The objective is to organize this space such that distances reflect the similarity to real data distributions.

Objective Functions

MLGAN utilizes principles from Distance Metric Learning, specifically the Min-Max Criterion (MMC). The training involves two primary distance metrics:

  • Intra-class distance ($L_{intra}$): The discriminator minimizes the distance between embeddings of the same class (real-to-real and fake-to-fake).
  • Inter-class distance ($L_{inter}$): The discriminator maximizes the distance between the real and fake clusters.

The discriminator minimizes $L_{intra} - \lambda L_{inter}$, while the generator aims to minimize $L_{inter}$, effectively pushing synthetic samples toward the real data cluster in the learned metric space.

Stability Enhancements

To ensure convergence and prevent embedding divergence, MLGAN incorporates:

  • Weight Clipping: Discriminator weights are constrained to a fixed range, ensuring the learned metric remains bounded.
  • Center Penalty: Embeddings are regularized toward predefined center vectors ($\mu_{data}$ and $\mu_g$), stabilizing the feature space.

Experimental Results

MLGAN was evaluated on four benchmark datasets: MNIST, CelebA, SVHN, and CIFAR-10.

Overview of generated samples from MLGAN across the four benchmark datasets: MNIST, CelebA, SVHN, and CIFAR-10.

Performance and Stability

The model's performance was quantified using the Inception Score (IS). On the SVHN dataset, MLGAN achieved an IS of 3.296, significantly outperforming the baseline DCGAN (1.032) and surpassing WGAN with gradient penalty (3.129). On CIFAR-10, MLGAN reached a score of 6.279, again exceeding WGAN-GP (6.069).

A key finding was MLGAN's robustness to architectural choices. While standard DCGANs often fail on complex datasets like SVHN, MLGAN maintained stability and produced recognizable images. Even without weight clipping or center penalties, the metric learning objective proved inherently more stable than traditional cross-entropy losses.

Handwritten digits generated by MLGAN on the MNIST dataset.

Discussion and Future Work

MLGAN demonstrates that a dynamically learned metric provides a more effective "teacher" for the generator than a static classifier. By providing a relative distance signal—telling the generator how far it is from reality—the training process becomes more intuitive and less prone to collapse.

Future research directions include incorporating label information (Conditional MLGAN) to further refine clustering and exploring more complex non-linear distance functions to capture intricate data manifolds.

Conclusion

MLGAN offers a robust alternative to standard GAN training by leveraging distance metric learning. By evolving the metric alongside the generator, the framework achieves superior image quality and enhanced training stability across diverse datasets.

Summary updated

BibTeX
@misc{dou2017metric,
  author = {Zi-Yi Dou},
  title = {{Metric Learning-based Generative Adversarial Network}},
  year = {2017},
  eprint = {1711.02792},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1711.02792},
}
Figure