NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning Implicit Generative Models Using Differentiable Graph Tests

Josip Djolonga, Andreas KrausearXiv 2017

Abstract

Implicit generative models have revolutionized artificial intelligence by enabling the synthesis of complex data distributions. However, training these models requires differentiable loss functions that can effectively distinguish between real and generated samples. We introduce a novel framework that transforms classical, non-differentiable graph-based statistical tests—specifically the Friedman-Rafsky (FR) and k-Nearest Neighbor (k-NN) tests—into differentiable functions. By employing probabilistic smoothing via Gibbs measures and the Matrix Tree Theorem, we derive "smoothed" test statistics that are not only differentiable but also exhibit higher statistical power than their discrete predecessors. Our results demonstrate that these graph-based losses provide a stable optimization landscape and outperform standard metrics like Maximum Mean Discrepancy (MMD) in high-dimensional image generation tasks.

Introduction

The training of implicit generative models, such as Generative Adversarial Networks (GANs), hinges on the ability to compare two sets of samples: the real data and the model's output. This is fundamentally a two-sample testing problem. While classical statistics offers powerful tools like the Friedman-Rafsky test (based on Minimum Spanning Trees) and k-NN tests, these algorithms are inherently discrete and non-differentiable. Consequently, they cannot be directly integrated into the backpropagation-based training loops of deep neural networks.

Differentiable Graph Tests

To overcome the differentiability barrier, we propose a framework for "probabilistic smoothing." Instead of selecting a single optimal graph (e.g., the unique Minimum Spanning Tree), we consider the space of all possible graphs and assign each a probability based on a Gibbs measure. Edges connecting similar points are assigned higher probabilities.

Smoothing the Friedman-Rafsky Test

The FR test relies on the number of edges in an MST that connect samples from different distributions. We utilize the Matrix Tree Theorem and Determinantal Point Processes (DPP) to compute the expected number of such edges across all possible spanning trees. This expectation is a differentiable function of the underlying data points.

Smoothing the k-NN Test

For k-NN tests, we use a forward-backward algorithm, similar to those used in chain Conditional Random Fields (CRFs), to compute the marginal probability that an edge belongs to a k-nearest neighbor set. This allows us to generalize Neighborhood Component Analysis (NCA) into a robust generative loss.

Smoothed test statistics for Friedman-Rafsky (FR) and Nearest Neighbor (NN) tests.

As shown in Figure 1, the resulting smoothed statistics $D_{1/2}^{FR}$ and $D_{1/2}^{NN}$ provide well-behaved, continuous functions that are suitable for optimization. These "smooth t-statistics" normalize the results, ensuring a stable landscape for training high-dimensional models.

Experimental Evaluation

We evaluated our method across synthetic and real-world datasets:

  • Statistical Power: In synthetic tests involving normal distributions, the smoothed graph tests significantly outperformed MMD, particularly when detecting differences in variance (scale) rather than just the mean (location).
  • Toy Datasets: On the "Two Moons" dataset, the models successfully learned complex non-linear geometries as the smoothing "temperature" parameter was annealed.
  • Image Generation: When applied to the MNIST dataset, our method produced realistic handwritten digits. Despite the simplicity of using pixel-wise Euclidean distances, the results were competitive with state-of-the-art Generative Moment Matching Networks.

Discussion and Conclusion

A key insight of this work is that smoothing is not merely a technical necessity for differentiability; it actually enhances statistical power. By integrating information from multiple possible graph structures, the test becomes more sensitive to the underlying data distribution.

While the computational complexity of the smoothed FR test ($O(n^3)$ due to matrix inversions) is higher than simpler losses, the use of fast Laplacian solvers offers a path toward scaling. Furthermore, the reliance on mini-batches suggests that future work should explore how these global graph properties can be better captured in small-sample regimes. By bridging classical algebraic graph theory with modern deep learning, we provide a powerful new class of loss functions for generative modeling.

Summary updated

BibTeX
@misc{djolonga2017learning,
  author = {Josip Djolonga and Andreas Krause},
  title = {{Learning Implicit Generative Models Using Differentiable Graph Tests}},
  year = {2017},
  eprint = {1709.01006},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1709.01006},
}
Figure