Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
\addbibresource

references.bib \AtBeginBibliography

Hitchhiker’s guide on Energy-Based Models: a comprehensive review on the relation with other generative models, sampling and statistical physics
Davide Carbone
INFN, Sezione di Torino, Via P. Giuria 1, 10125 Torino, Italy
and Dipartimento di Scienze Matematiche, Politecnico di Torino, Corso Duca degli Abruzzi 24, 10129 Torino, Italy
davide.carbone@polito.it

Corresponding author: Davide Carbone, davide.carbone@polito.it
 

Abstract

Energy-Based Models (EBMs) have emerged as a powerful framework in the realm of generative modeling, offering a unique perspective that aligns closely with principles of statistical mechanics. This review aims to provide physicists with a comprehensive understanding of EBMs, delineating their connection to other generative models such as Generative Adversarial Networks (GANs), Variational Autoencoders (VAEs), and Normalizing Flows. We explore the sampling techniques crucial for EBMs, including Markov Chain Monte Carlo (MCMC) methods, and draw parallels between EBM concepts and statistical mechanics, highlighting the significance of energy functions and partition functions. Furthermore, we delve into state-of-the-art training methodologies for EBMs, covering recent advancements and their implications for enhanced model performance and efficiency. This review is designed to clarify the often complex interconnections between these models, which can be challenging due to the diverse communities working on the topic.
 

1 Introduction

1.1 Generative models

The problem of description of data through a mathematical model is very old, being the basis of scientific method. The set of measurements use to fulfill the role that contemporary data scientists now refer to as a dataset. Presently, the model can take the form of an exceedingly complex neural network, but the underlying extrapolation remains akin to P.S. Laplace’s famous deterministic statement[laplace2012philosophical]: "An intellect which at a certain moment would know all forces [data] that set nature in motion […] would be uncertain and the future just like the past could be present before its eyes". One can easily extend this reasoning, asserting that the more data one possesses, the more robust and detailed the model that can be constructed atop them. This leads to enhanced predictions and greater stability concerning unforeseen behaviors.
This line of thought was boosted in the previous century with the advent of automatic calculators, and the velocity of development becomes astounding. For instance, consider the remarkable computational power difference between your smartphone and the computer used for the Apollo program by NASA in the 1960s [comparison]. Hence, the quest for data has become an indispensable aspect of contemporary science.
To delve deeper into this issue, let us construct a historical metaphor. One of the early modern achievements in observational astronomy is Kepler’s laws. The genesis of such results is deeply rooted in a vast collection of observational data amassed by T. Brahe [brahe]. Kepler’s formulation was, in fact, motivated by the necessity to explain these astronomical measurements. In a simplified analogy, we observe the dichotomy between the "model," embodied by Kepler, and the "dataset," represented in this narrative by Brahe. Since the 17th century, these two actors have played equally fundamental roles in the advancement of science, taking turns on the stage with the same importance. Consider, for instance, the pivotal role played by Faraday’s experiments in understanding electromagnetism [al2015birth], long before Maxwell’s laws. Or, conversely, the impact of theory of Relativity[relat] way before its experimental confirmation.
In recent years, particularly during the 2000s, we have witnessed a profound paradigm shift represented by the Big Data Era[bigdata]. Thanks to the aforementioned technological advancements in computer science, the volume of generated scientific (and not) data has dramatically increased, resulting from advancements in simulation and storage capabilities. Furthermore, there has been a growing collection of data on human activities, including images, text, sounds, and more.

Returning to the historical analogy, it is akin to Brahe suddenly providing Kepler with a thousand times the amount of data that the latter was accustomed to. This shift posed a methodological problem in what we now refer to as data science, and this is where the machine learning approach came into play[fradkov2020early]. The models required to process Big Data had already been theoretically studied since the invention of the perceptron[mcculloch1943logical]. Their application was constrained by computational power in the last century, but, as a peculiar example of convergent development, they became the primary tools in the toolbox of data scientists in the 2000s, simultaneously to the appearance of Big Data on the stage.

There is indeed a discontinuity that deserves more attention: the increasing collection of data generated by humans. The term Big Data is sometimes limited to images, sounds, videos, text, and metadata resulting from human activities, not just on the internet. Unlike scientific measurements, having access to an extensive quantity of information produced by humans opened Pandora’s box, prompting the natural question: can we build artificial intelligence by leveraging Big Data? In other words, can we construct a machine capable of generating data as humans do, by training it in some smart way? Data here is to be understood in a broad sense, encompassing new theorems, art pieces, images, videos, and even novels.
Generative models represent, in this sense, the most recent breakthrough in technological advancement towards intelligent-like machines. It is complicated to provide a general definition, and there are already many available from different sources[gene, gene2]. However, if we informally focus on those already known to the general public, such as Generative Pre-Trained Transformers (GPT)[gene3], the common traits of most definitions are few. Firstly, generative models require a substantial amount of data for training, in addition to the selection of a precise architecture, which goes far beyond the original perceptron. Secondly, the training is probably not biologically inspired, i.e., we do not learn through backpropagation[grossberg1987competitive], which is the most commonly used training technique in machine learning. For completeness, it is worth noting that this thesis is still debated in neuroscience[lillicrap2020backpropagation]. Thirdly, a generative model is not necessarily informative about the data distribution; for instance, ChatGPT could achieve astounding results in text generation, but the training machine does not provide knowledge about some general features of text generated by humans.
Returning to the historical metaphor: nowadays, we are able to build "BraheGPT," which can generate and gather new plausible measurements about the orbits of planets in unobserved planetary systems after training on observed data from the solar system. However, it is not Kepler; deductive reasoning is not necessary to generate new data instances, although it remains fundamental to understanding the world. Von Neumann would certainly adapt his famous statement[dyson2004meeting] about overfitting to modern data science, cautioning against the ability to generate examples without a general picture.
Prominent data scientists, such as Yann LeCun, have recently emphasized that the use of interpretable generative models is crucial for achieving a "unified world model for AI capable of planning"[lecun]. This thesis becomes imperative in the realm of computational sciences, where qualitative generation alone is insufficient as a benchmark to evaluate model performance. In sectors like Molecular Dynamics, Biochemistry, and similar fields, the model must convey substantial information about the dataset. The generative models that excel in terms of interpretability, which form the main focus of the present work, are precisely the Energy-Based Models (EBMs). These models offer a unique advantage in their ability to provide insights into the underlying mechanisms of the data they generate. In areas such as Molecular Dynamics and Biochemistry, where understanding the intricate relationships within the dataset is crucial, the interpretability of EBMs stands out.
In adopting EBMs, researchers and practitioners gain not only the capacity to generate high-quality data but also a clearer understanding of the factors influencing the generated outputs. This interpretability is indispensable in domains where the model’s ability to convey meaningful information about the dataset is paramount. As the pursuit of a unified world model for AI continues, the emphasis on interpretable generative models, particularly EBMs, plays a pivotal role in bridging the gap between data generation and comprehensive understanding.

1.2 A long story: from Boltzmann-Gibbs ensemble to the advent of EBMs

After providing a historical overview of generative models, this section is dedicated to exploring the origin and development of Energy-Based Models (EBMs). As we delve into this discussion, it becomes evident that the theoretical foundation of such generative models exists under different names at the intersection of various fields, including statistical physics, probability theory, computer science, and sampling, among others. In this section, we emphasize a historical perspective to shed light on the evolutionary trajectory of EBMs. While we touch upon the overarching theories, more in-depth theoretical discussions are reserved for subsequent chapters. We believe that this review serves as a valuable resource for readers across diverse fields enabling them to construct a comprehensive understanding of what constitutes an Energy-Based Model by tracing the genesis of this topic.
The first ingredient of the story is the Boltzmann-Gibbs measure, a fundamental concept in statistical mechanics, and has its origins in the works of Ludwig Boltzmann and Josiah Willard Gibbs during the late 19th century. These two influential physicists independently contributed to the development of statistical mechanics, providing a bridge between the microscopic behavior of particles and macroscopic thermodynamic properties.
Ludwig Boltzmann made significant strides in understanding the statistical nature of gases, introducing what is now known as the Boltzmann distribution[boltzmann1868studien]. Boltzmann’s statistical approach, which related the statistical weight of different microscopic configurations to their entropy, laid the groundwork for the probabilistic description of thermodynamic systems.
Josiah Willard Gibbs, in parallel with Boltzmann, extended these ideas to develop the canonical ensemble, introducing what is commonly referred to as the Gibbs measure[gibbs1902elementary]. He provides a mathematical framework for calculating thermodynamic properties based on the statistical distribution of particles in a given system. The Boltzmann-Gibbs measure, which emerged from the synthesis of these ideas, describes the probability distribution of particles in different energy states at thermal equilibrium at temperature T𝑇Titalic_T. It has become a cornerstone of statistical mechanics, applicable to diverse physical systems, including gases, liquids, and solids. We informally recall its definition: given the state of the system xΩ𝑥Ωx\in\Omegaitalic_x ∈ roman_Ω, where ΩΩ\Omegaroman_Ω is the so-called phase space, and an energy function U:Ω+:𝑈ΩsuperscriptU:\Omega\to\mathbb{R}^{+}italic_U : roman_Ω → blackboard_R start_POSTSUPERSCRIPT + end_POSTSUPERSCRIPT, we can express the associated probability density function

ρ(x)eβU(x)proportional-to𝜌𝑥superscript𝑒𝛽𝑈𝑥\rho(x)\propto e^{-\beta U(x)}italic_ρ ( italic_x ) ∝ italic_e start_POSTSUPERSCRIPT - italic_β italic_U ( italic_x ) end_POSTSUPERSCRIPT (1.1)

where β=1/kBT𝛽1subscript𝑘𝐵𝑇\beta=1/k_{B}Titalic_β = 1 / italic_k start_POSTSUBSCRIPT italic_B end_POSTSUBSCRIPT italic_T, kBsubscript𝑘𝐵k_{B}italic_k start_POSTSUBSCRIPT italic_B end_POSTSUBSCRIPT being the Boltzmann constant. A detailed mathematical description will be provided in the next chapters.
The analysis of the impact of Boltzmann-Gibbs ensemble on physics would require a full monography per se; for the sake of the present work, we directly advance to 1924, when E. Ising presented his PhD thesis[isi]. The so called Ising model is a fundamental mathematical model in statistical mechanics. It serves as a simplified yet powerful representation of magnetic systems, particularly in understanding the behavior of spins in a lattice ΛΛ\Lambdaroman_Λ — for simplicity, we can imagine a graph with N𝑁Nitalic_N nodes. In the Ising model, each lattice site is associated with a magnetic spin, which can take two possible values, usually denoted as "up" or "down", that is Ω={1,1}NΩsuperscript11𝑁\Omega=\{-1,1\}^{N}roman_Ω = { - 1 , 1 } start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT. The interactions between spins are typically modeled using a simple energy function, namely

UIs(x)=ijJijxixjμjhjxjsubscript𝑈𝐼𝑠𝑥subscriptdelimited-⟨⟩𝑖𝑗subscript𝐽𝑖𝑗subscript𝑥𝑖subscript𝑥𝑗𝜇subscript𝑗subscript𝑗subscript𝑥𝑗\displaystyle U_{Is}(x)=-\sum_{\langle ij\rangle}J_{ij}x_{i}x_{j}-\mu\sum_{j}h% _{j}x_{j}italic_U start_POSTSUBSCRIPT italic_I italic_s end_POSTSUBSCRIPT ( italic_x ) = - ∑ start_POSTSUBSCRIPT ⟨ italic_i italic_j ⟩ end_POSTSUBSCRIPT italic_J start_POSTSUBSCRIPT italic_i italic_j end_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT - italic_μ ∑ start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT italic_h start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT (1.2)

Let us briefly clarify the notation: i,jΛ𝑖𝑗Λi,j\in\Lambdaitalic_i , italic_j ∈ roman_Λ are indexes of sites in the lattice; ijdelimited-⟨⟩𝑖𝑗\langle ij\rangle⟨ italic_i italic_j ⟩ indicates that the sum is restricted to first neighbours and Jijsubscript𝐽𝑖𝑗J_{ij}italic_J start_POSTSUBSCRIPT italic_i italic_j end_POSTSUBSCRIPT is the strength of the interaction. The field hisubscript𝑖h_{i}italic_h start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT instead individually acts on each site and μ𝜇\muitalic_μ is just a constant that traditionally corresponds to magnetic moment. In laymen terms, each magnetic spin interacts with its first neighbours and with an external field. The alignment of spins is encouraged.
In considering (1.1) as associated to UIssubscript𝑈𝐼𝑠U_{Is}italic_U start_POSTSUBSCRIPT italic_I italic_s end_POSTSUBSCRIPT, the primary focus is often on the behavior of the system as a function of temperature. In a nutshell, at high temperatures, thermal fluctuations dominate, and the system exhibits no long-range order. As the temperature decreases, there is a critical point at which the system undergoes a phase transition, leading to spontaneous magnetization and the emergence of long-range order.
For some decades the interest for Ising model and its extensions was confined to physics. The motivation for invoking such a model in the present work is the following: in the 80s a fundamental connection between Ising model and data science manifested through Hopfield networks[hopfield1982neural] and Boltzmann machines[ackley1985learning]. Both can be viewed as an Ising lattice where interactions are not confined to first neighbors. Apart from the initial summation, which, for the former, extends to i,jΛfor-all𝑖𝑗Λ\forall i,j\in\Lambda∀ italic_i , italic_j ∈ roman_Λ rather than just ijdelimited-⟨⟩𝑖𝑗\langle ij\rangle⟨ italic_i italic_j ⟩, the energy function bears resemblance to (1.2). From a statistical physics standpoint, the distinction between a Hopfield network and Boltzmann machines lies solely in the temperature value.
The purpose of the former is pattern recognition and associative memory tasks. A distinctive feature of Hopfield networks is their proficiency in storing and retrieving patterns through symmetric connections between neurons, that is Ising sites, in the network. In practice, when provided with a set of network configurations yλΩsuperscript𝑦𝜆Ωy^{\lambda}\in\Omegaitalic_y start_POSTSUPERSCRIPT italic_λ end_POSTSUPERSCRIPT ∈ roman_Ω representing patterns, denoted by λ=1,,n𝜆1𝑛\lambda=1,\dots,nitalic_λ = 1 , … , italic_n, one constructs the coupling J𝐽Jitalic_J as follows:

Jij=1nλ=1nyiλyjλsubscript𝐽𝑖𝑗1𝑛superscriptsubscript𝜆1𝑛superscriptsubscript𝑦𝑖𝜆superscriptsubscript𝑦𝑗𝜆\displaystyle J_{ij}={\frac{1}{n}}\sum_{\lambda=1}^{n}y_{i}^{\lambda}y_{j}^{\lambda}italic_J start_POSTSUBSCRIPT italic_i italic_j end_POSTSUBSCRIPT = divide start_ARG 1 end_ARG start_ARG italic_n end_ARG ∑ start_POSTSUBSCRIPT italic_λ = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT italic_y start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_λ end_POSTSUPERSCRIPT italic_y start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_λ end_POSTSUPERSCRIPT (1.3)

This involves employing the Hebbian rule[hebb1949organization] "neurons wire together if they fire together"[lowel1992selection], but further specifications[storkey1997increasing] are available. This phase is commonly referred to as the training of the network. Subsequently, one can define a retrieval iterative dynamics starting from any configuration xk=0Ωsuperscript𝑥𝑘0Ωx^{k=0}\in\Omegaitalic_x start_POSTSUPERSCRIPT italic_k = 0 end_POSTSUPERSCRIPT ∈ roman_Ω, as exemplified by the equation:

xk+1=sgn(Jxk+h)kformulae-sequencesuperscript𝑥𝑘1sgn𝐽superscript𝑥𝑘𝑘x^{k+1}=\text{sgn}(Jx^{k}+h)\quad\quad k\in\mathbb{N}italic_x start_POSTSUPERSCRIPT italic_k + 1 end_POSTSUPERSCRIPT = sgn ( italic_J italic_x start_POSTSUPERSCRIPT italic_k end_POSTSUPERSCRIPT + italic_h ) italic_k ∈ blackboard_N (1.4)

Here, J𝐽Jitalic_J represents the coupling matrix defined element-wise in (1.3), and hhitalic_h is a bias vector that influences the preferences for ’up’ or ’down’. It is noteworthy that in a Hopfield network, there is no use of the Boltzmann-Gibbs ensemble; the objective is to construct a dynamical system with prescribed attractors, which are the minima of U(x)𝑈𝑥U(x)italic_U ( italic_x ) by design.
Boltzmann Machines share the same structure and energy function but the goal extends beyond the mere retrieval of patterns; it is to model their overall distribution. To illustrate this concept, consider a finite set of n𝑛nitalic_n natural images of cats and dogs. A meticulously designed Hopfield Network could perfectly retrieve any of these examples. On the contrary, a trained Boltzmann Machine aspires to generate new instances of cats and dogs, capturing, in a sense, the distribution of such images. The objective appears to be on a different level of difficulty: although possibly big, the cardinality of the set of patterns is finite; the number of possible variations of cats and dogs is not. Thus, one can immediately guess why the training and generation phases (n.b. it is no more just a retrieval) are completely different w.r.t. Hopfield Networks. The take home message is the hypothesis that the distribution of the given patterns can be described by a Boltzmann-Gibbs ensemble associated to the energy of the Hopfield Network at temperature T𝑇Titalic_T.
It is convenient to consider Boltzmann Machines as a specific instance of Energy-Based Models, a term introduced by Hinton et al. [teh2003energy], to describe both training and generation phases. EBMs differ from Boltzmann Machines in the use of a generic parametric energy Uθ(x)subscript𝑈𝜃𝑥U_{\theta}(x)italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) instead of the usual choice made for the latter. Here, θΘ𝜃Θ\theta\in\Thetaitalic_θ ∈ roman_Θ needs to be selected and trained so that the Boltzmann-Gibbs ensemble ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT associated with Uθ(x)subscript𝑈𝜃𝑥U_{\theta}(x)italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) "fits well" the distribution of the given patterns, which we refer to as ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. After training the EBM, the generative phase involves sampling equilibrium configurations from ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT. Specifically, a Boltzmann Machine corresponds to an EBM with the choice of U(x)𝑈𝑥U(x)italic_U ( italic_x ) as the energy of a Hopfield Network and θ=J𝜃𝐽\theta=Jitalic_θ = italic_J.
Despite their conceptual simplicity, both training and generation represent fundamental open problems that intersect multiple research fields. In essence, sampling from a Boltzmann-Gibbs ensemble is a challenging task in general, and unfortunately, it is necessary even during the training phase. For this reason, the use of Boltzmann Machines was limited to toy models until the proposal of the Contrastive Divergence algorithm by Hinton [hinton2002training].
This procedure, along with its generalizations, made it possible to apply EBMs to practical problems. Moreover, thanks to the adoption of a deep neural network [xie2016theory] as Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT, the interest towards this class of generative models critically increased and in 2010s the use of EBMs for state-of-the-art tasks became standard. However, all that glitters is not gold. Despite its success in generating high-quality individual samples, the use of Contrastive Divergence is known to be biased. For instance, it could happen that individual images are correctly generated, but ensemble properties as the relative proportion of the two species is incorrect. Although Hinton et al. originally claimed that this bias is generally small [carreira2005contrastive], numerous counterexamples have been shown in the more than 20 years since their original paper. The absence of novel paradigm shifts, coupled with the rise of alternative generative models (e.g., diffusion-based ones [song2020score]), has reduced attention on EBMs and consequently on Boltzmann Machines.
The main purpose of the present work is to review the main features of EBMs, in particular in relation with generative modelling, sampling and Statistical Physics. The idea is to provide a useful orientation guide for people coming from very different communities that would like to investigate such topics; we believe that a resource of this kind could be beneficial to favor further developments in the field of energy-based modelling. We will present instances of fruitful interplay between Physics and generative modelling throughout the next sections.
The structure of the review will be the following:

  • in Section 2 we define Energy-Based Models and we highlight the main difficulty related to its training through cross-entropy minimization;

  • in Section 3 we present a review of the principal generative models as opposed to EBMs. Then, we conclude the section with a comparative scheme between all the presented models, i.e. EBMs, Generative Adversarial Networks, Variational Auto-Encoders, Normalizing Flow and Diffusion-Based Generative Models;

  • in Section 4 we review the main MCMC methods used to sample from a Boltzmann-Gibbs ensemble, hence used in the context of EBM training to generate the necessary sample used to perform gradient descent on cross-entropy;

  • in Section 5 we summarize the derivation of Boltzmann-Gibbs equilibrium ensemble, motivating the importance of concepts as free energy in the context of statistical learning;

  • in Section 6 we present the state of the art about EBM training, that is Constrastive Divergence algorithm, and we highlight his limitation; in conclusion, we provide some references about recent works trying to overcome the main issues of such procedure.

2 Definition of EBM

In this Section, we provide the basic formal definition of Energy-Based Model. We will adopt the notation and the presented assumption throughout the present work. First of all, the problem we consider can be formulated as follows: we assume that we are given n𝑛n\in\mathbb{N}italic_n ∈ blackboard_N data points {xi}i=1nsuperscriptsubscriptsuperscriptsubscript𝑥𝑖𝑖1𝑛\{x_{i}^{*}\}_{i=1}^{n}{ italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT in dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT drawn from an unknown probability distribution that is absolutely continuous with respect to the Lebesgue measure on dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, with a positive probability density function (PDF) ρ(x)>0subscript𝜌𝑥0\rho_{*}(x)>0italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) > 0 (also unknown). This is a standard problem in statistical learning, where learning from data here refers to the ability to fit the data distribution and to generate new examples. More precisely, our aim is to estimate ρ(x)subscript𝜌𝑥\rho_{*}(x)italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) via an energy-based model (EBM), i.e. to find a suitable energy function in a parametric class, Uθ:d[0,):subscript𝑈𝜃superscript𝑑0U_{\theta}:\mathbb{R}^{d}\to[0,\infty)italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT → [ 0 , ∞ ) with parameters θΘ𝜃Θ\theta\in\Thetaitalic_θ ∈ roman_Θ, such that the associated Boltzmann-Gibbs PDF

ρθ(x)=Zθ1eUθ(x);Zθ=deUθ(x)𝑑xformulae-sequencesubscript𝜌𝜃𝑥superscriptsubscript𝑍𝜃1superscript𝑒subscript𝑈𝜃𝑥subscript𝑍𝜃subscriptsuperscript𝑑superscript𝑒subscript𝑈𝜃𝑥differential-d𝑥\rho_{\theta}(x)=Z_{\theta}^{-1}e^{-U_{\theta}(x)};\qquad Z_{\theta}=\int_{% \mathbb{R}^{d}}e^{-U_{\theta}(x)}dxitalic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) = italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT italic_e start_POSTSUPERSCRIPT - italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) end_POSTSUPERSCRIPT ; italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_e start_POSTSUPERSCRIPT - italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) end_POSTSUPERSCRIPT italic_d italic_x (2.1)

is an approximation of the target density ρ(x)subscript𝜌𝑥\rho_{*}(x)italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ). Actually, any probability density function can be written as a Boltzmann Gibbs ensemble for a particular choice of U(x)𝑈𝑥U(x)italic_U ( italic_x ). The normalization factor Zθsubscript𝑍𝜃Z_{\theta}italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is known as the partition function in statistical physics [lifshitz], see also Section 5, and as the evidence in Bayesian statistics[feroz2008multimodal].

Remark 2.1.

Even if Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is known, an explicit analytical computation of the partition function is generally unfeasable. If the dimension d𝑑ditalic_d is big enough, the integral defining Zθsubscript𝑍𝜃Z_{\theta}italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT cannot be computed using standard quadrature methods. The only possibility is Monte-Carlo sampling[liu2001monte]. To employ such method, one can express the partition function as an expectation 𝔼0subscript𝔼0\mathbb{E}_{0}blackboard_E start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT with respect to a chosen probability density function ρ0subscript𝜌0\rho_{0}italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, i.e.

Zθ=𝔼0[eUθρ0]subscript𝑍𝜃subscript𝔼0delimited-[]superscript𝑒subscript𝑈𝜃subscript𝜌0Z_{\theta}=\mathbb{E}_{0}\left[\frac{e^{-U_{\theta}}}{\rho_{0}}\right]italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = blackboard_E start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT [ divide start_ARG italic_e start_POSTSUPERSCRIPT - italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT end_POSTSUPERSCRIPT end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT end_ARG ] (2.2)

The selected density must be known pointwise in dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, including the normalization constant, and it should be easy to sample from. If these conditions are met, one can compute the partition function by simply replacing the expectation in (2.2) with the corresponding empirical average computed using samples drawn from ρ0subscript𝜌0\rho_{0}italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT. Unfortunately, finding a probability density that satisfies these properties is challenging. For a general choice that is not tailored to eUθsuperscript𝑒subscript𝑈𝜃e^{-U_{\theta}}italic_e start_POSTSUPERSCRIPT - italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT end_POSTSUPERSCRIPT, the estimator is likely to be very poor, characterized by a very large, or even infinite, coefficient of variation.

One advantage of EBMs is that they provide generative models that do not require the explicit knowledge of Zθsubscript𝑍𝜃Z_{\theta}italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT. In Section 4.4 we will review some routines that can in principle be used to sample ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT knowing only Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT – the design of such methods is an integral part of the problem of building an EBM.

To proceed we need some assumptions on the parametric class of energy:

Assumption 2.1.

For all θΘ𝜃Θ\theta\in\Thetaitalic_θ ∈ roman_Θ:

  1. 1.

    UθC2(d);L+:Uθ(x)Lxd;:formulae-sequencesubscript𝑈𝜃superscript𝐶2superscript𝑑𝐿subscriptformulae-sequencenormsubscript𝑈𝜃𝑥𝐿for-all𝑥superscript𝑑U_{\theta}\in C^{2}(\mathbb{R}^{d});\qquad\exists L\in\mathbb{R}_{+}:\|\nabla% \nabla U_{\theta}(x)\|\leq L\quad\forall x\in\mathbb{R}^{d};italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ∈ italic_C start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ( blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ) ; ∃ italic_L ∈ blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT : ∥ ∇ ∇ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ∥ ≤ italic_L ∀ italic_x ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ;

  2. 2.

    a+and a compact set 𝒞d:xUθ(x)a|x|2xd𝒞.:𝑎subscriptand a compact set 𝒞dformulae-sequence𝑥subscript𝑈𝜃𝑥𝑎superscript𝑥2for-all𝑥superscript𝑑𝒞\exists a\in\mathbb{R}_{+}\text{and a compact set $\mathcal{C}\in\mathbb{R}^{d% }$}:\ x\cdot\nabla U_{\theta}(x)\geq a|x|^{2}\quad\forall x\in\mathbb{R}^{d}% \setminus{\mathcal{C}}.∃ italic_a ∈ blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT and a compact set caligraphic_C ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT : italic_x ⋅ ∇ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ≥ italic_a | italic_x | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ∀ italic_x ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ∖ caligraphic_C .

The need for the first assumption will be discussed in Section 4.4: it is related to wellposedness and convergence properties of the dynamics used for sampling, i.e. Langevin dynamics and its specifications. The second assumption guarantees that Zθ<subscript𝑍𝜃Z_{\theta}<\inftyitalic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT < ∞ (i.e. we can associate a PDF ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT to Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT via (2.1) for any θΘ𝜃Θ\theta\in\Thetaitalic_θ ∈ roman_Θ). We provide now two important definitions:

Definition 2.1 (Convexity).

A function φ:d(,+]:𝜑superscript𝑑\varphi:\mathbb{R}^{d}\to(-\infty,+\infty]italic_φ : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT → ( - ∞ , + ∞ ] is convex if given 0<λ<10𝜆10<\lambda<10 < italic_λ < 1 and x1,x2dsubscript𝑥1subscript𝑥2superscript𝑑x_{1},x_{2}\in\mathbb{R}^{d}italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT such that x1x2subscript𝑥1subscript𝑥2x_{1}\neq x_{2}italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ≠ italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT, the following is true

φ(tx1+(1t)x2)tφ(x1)+(1t)φ(x2)𝜑𝑡subscript𝑥11𝑡subscript𝑥2𝑡𝜑subscript𝑥11𝑡𝜑subscript𝑥2\displaystyle\varphi\left(tx_{1}+(1-t)x_{2}\right)\leq t\varphi\left(x_{1}% \right)+(1-t)\varphi\left(x_{2}\right)italic_φ ( italic_t italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT + ( 1 - italic_t ) italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) ≤ italic_t italic_φ ( italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + ( 1 - italic_t ) italic_φ ( italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) (2.3)
Definition 2.2 (Log-Concavity).

A density function ρ𝜌\rhoitalic_ρ with respect to Lebesgue measure on (d,d)superscript𝑑superscript𝑑(\mathbb{R}^{d},\mathcal{B}^{d})( blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT , caligraphic_B start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ) is log-concave if ρ=eφ𝜌superscript𝑒𝜑\rho=e^{-\varphi}italic_ρ = italic_e start_POSTSUPERSCRIPT - italic_φ end_POSTSUPERSCRIPT where φ𝜑\varphiitalic_φ is convex.

A non-convex function could have more than one local but not global minima; conversely, a non-log-concave probability density could have more than local maxima, which are called modes. It is important to stress that Assumption (2.1) does not imply that Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is convex (i.e. that ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is log-concave): in fact, we will be most interested in situations where Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT has multiple local minima so that ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is multimodal. We will elaborate on the topic in Section 4.4. It is well known as for optimization problems, non-convex cases are the most complicated. Similarly, sampling from a non-log-concave probability density function (PDF) can be extremely challenging. Another assumption we will adopt is:

Assumption 2.2.

Without loss of generality θΘ:ρθ=ρ:subscript𝜃Θsubscript𝜌subscript𝜃subscript𝜌\exists\theta_{*}\in\Theta\ :\ \rho_{\theta_{*}}=\rho_{*}∃ italic_θ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∈ roman_Θ : italic_ρ start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, that is ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT is in the parametric class of ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT.

The aims of EBMs are primarily to identify θsubscript𝜃\theta_{*}italic_θ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT and to sample ρθsubscript𝜌subscript𝜃\rho_{\theta_{*}}italic_ρ start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT end_POSTSUBSCRIPT; in the process, we will also show how to estimate Zθsubscript𝑍subscript𝜃Z_{\theta_{*}}italic_Z start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT end_POSTSUBSCRIPT.

Example 2.1.

Let us present a simple example to visualize the relation between convexity and log-concavity. In Figure 1 we plot side by side the PDF of a Gaussian mixture in 1D and the associated potential

Uθ(x)=log[pexp((xμ1)2σ12)+(1p)exp((xμ2)2σ22)]subscript𝑈𝜃𝑥𝑝superscript𝑥subscript𝜇12superscriptsubscript𝜎121𝑝superscript𝑥subscript𝜇22superscriptsubscript𝜎22U_{\theta}(x)=\log\left[p\exp\left(-\dfrac{(x-\mu_{1})^{2}}{\sigma_{1}^{2}}% \right)+(1-p)\exp\left(-\dfrac{(x-\mu_{2})^{2}}{\sigma_{2}^{2}}\right)\right]italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) = roman_log [ italic_p roman_exp ( - divide start_ARG ( italic_x - italic_μ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG start_ARG italic_σ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG ) + ( 1 - italic_p ) roman_exp ( - divide start_ARG ( italic_x - italic_μ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG start_ARG italic_σ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG ) ] (2.4)
Refer to caption
Figure 1: Gaussian Mixture. Plot of PDF with sampled histogram and associated energy Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT.

where θ={p,μ1,2,σ1,2}𝜃𝑝subscript𝜇12subscript𝜎12\theta=\{p,\mu_{1,2},\sigma_{1,2}\}italic_θ = { italic_p , italic_μ start_POSTSUBSCRIPT 1 , 2 end_POSTSUBSCRIPT , italic_σ start_POSTSUBSCRIPT 1 , 2 end_POSTSUBSCRIPT }. The specific values are p=0.7𝑝0.7p=0.7italic_p = 0.7, μ1=0subscript𝜇10\mu_{1}=0italic_μ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = 0, μ2=5subscript𝜇25\mu_{2}=5italic_μ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT = 5, σ1=1subscript𝜎11\sigma_{1}=1italic_σ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = 1 and σ2=0.5subscript𝜎20.5\sigma_{2}=0.5italic_σ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT = 0.5. It is clear the correspondence between minima of Uθ(x)subscript𝑈𝜃𝑥U_{\theta}(x)italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) and maxima, that is modes, of ρ𝜌\rhoitalic_ρ.

2.1 Cross-entropy minimization

Once we defined an EBM, we need to measure its quality with respect to the data distribution. Possibly, this would provide a way to train its parameters. Hence, we define some important quantities:

Definition 2.3.

Consider two probability densities on dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT and absolutely continuous with respect to Lebesgue measure, namely ρ1subscript𝜌1\rho_{1}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and ρ2subscript𝜌2\rho_{2}italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT. We define

  1. 1.

    Cross Entropy

    H(ρ1,ρ2)=dlogρ2(x)ρ1(x)𝑑x𝐻subscript𝜌1subscript𝜌2subscriptsuperscript𝑑subscript𝜌2𝑥subscript𝜌1𝑥differential-d𝑥H(\rho_{1},\rho_{2})=-\int_{\mathbb{R}^{d}}\log\rho_{2}(x)\rho_{1}(x)dxitalic_H ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) = - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT roman_log italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x (2.5)
  2. 2.

    Kullback-Leibler divergence[kullback1951information]

    DKL(ρ1ρ2)=dρ1(x)log(ρ1(x)ρ2(x))𝑑xsubscript𝐷KLconditionalsubscript𝜌1subscript𝜌2subscriptsuperscript𝑑subscript𝜌1𝑥subscript𝜌1𝑥subscript𝜌2𝑥differential-d𝑥{\displaystyle D_{\text{KL}}(\rho_{1}\parallel\rho_{2})=\int_{\mathbb{R}^{d}}% \rho_{1}(x)\ \log\left({\frac{\rho_{1}(x)}{\rho_{2}(x)}}\right)\ dx}italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ) roman_log ( divide start_ARG italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ( italic_x ) end_ARG ) italic_d italic_x (2.6)
  3. 3.

    Entropy

    H(ρ1)=dlogρ1(x)ρ1(x)𝑑x𝐻subscript𝜌1subscriptsuperscript𝑑subscript𝜌1𝑥subscript𝜌1𝑥differential-d𝑥H(\rho_{1})=-\int_{\mathbb{R}^{d}}\log\rho_{1}(x)\rho_{1}(x)dxitalic_H ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) = - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT roman_log italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x (2.7)

The KL divergence is a widely used estimator for the dissimilarity between probability measures. It satisfies the non-negativity condition

DKL(ρ1ρ2)0,DKL(ρ1ρ2)=0ρ1=ρ2a.e.iffformulae-sequencesubscript𝐷KLconditionalsubscript𝜌1subscript𝜌20subscript𝐷KLconditionalsubscript𝜌1subscript𝜌20subscript𝜌1subscript𝜌2a.e.D_{\text{KL}}(\rho_{1}\parallel\rho_{2})\geq 0,\quad\quad D_{\text{KL}}(\rho_{% 1}\parallel\rho_{2})=0\iff\rho_{1}=\rho_{2}\,\,\text{a.e.}italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) ≥ 0 , italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) = 0 ⇔ italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT a.e. (2.8)

However, it is not a proper distance since it is not symmetric and it does not satisfy triangular inequality. The following trivial lemma relates the three quantities we introduced in Definition 2.3:

Lemma 2.1.

The following equality holds for any choice of PDFs ρ1subscript𝜌1\rho_{1}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and ρ2subscript𝜌2\rho_{2}italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT

H(ρ1,ρ2)=H(ρ2)+DKL(ρ2ρ1)𝐻subscript𝜌1subscript𝜌2𝐻subscript𝜌2subscript𝐷KLconditionalsubscript𝜌2subscript𝜌1H(\rho_{1},\rho_{2})=H(\rho_{2})+D_{\text{KL}}(\rho_{2}\parallel\rho_{1})italic_H ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) = italic_H ( italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) + italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) (2.9)

One can also use the cross-entropy of the model density ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT relative to the target density ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT as an estimate of diversity between the two PDFs; in such case, 2.5 simplifies becoming

H(ρ,ρθ)=logZθ+dUθ(x)ρ(x)𝑑x𝐻subscript𝜌subscript𝜌𝜃subscript𝑍𝜃subscriptsuperscript𝑑subscript𝑈𝜃𝑥subscript𝜌𝑥differential-d𝑥H(\rho_{*},\rho_{\theta})=\log Z_{\theta}+\int_{\mathbb{R}^{d}}U_{\theta}(x)% \rho_{*}(x)dxitalic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) = roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT + ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x (2.10)

Because of 2.9, the difference between the cross-entropy and the KL divergence is H(ρ)𝐻subscript𝜌H(\rho_{*})italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ), a term that depends just on the data distribution. Hence, the optimal parameters θsuperscript𝜃\theta^{*}italic_θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT are solution of an optimization problem on ΘΘ\Thetaroman_Θ, namely

θ=argminθΘDKL(ρ||ρθ)=argminθΘH(ρ,ρθ),superscript𝜃subscriptargmin𝜃Θsubscript𝐷KLsubscript𝜌subscript𝜌𝜃subscriptargmin𝜃Θ𝐻subscript𝜌subscript𝜌𝜃\theta^{*}=\operatorname*{arg\,min}_{\theta\in\Theta}D_{\text{KL}}(\rho_{*}% \lvert\rvert\rho_{\theta})=\operatorname*{arg\,min}_{\theta\in\Theta}H(\rho_{*% },\rho_{\theta}),italic_θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT = start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT | | italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) = start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) , (2.11)

meaning that the entropy of ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT plays no active role in solving such minimization problem. There is a subtle issue in this reasoning: unlike KL divergence, the cross-entropy is not bounded from below, and in particular H(ρ,ρ)H(ρ)0𝐻𝜌𝜌𝐻𝜌0H(\rho,\rho)\coloneqq H(\rho)\neq 0italic_H ( italic_ρ , italic_ρ ) ≔ italic_H ( italic_ρ ) ≠ 0. That is, we should compute H(ρ)𝐻subscript𝜌H(\rho_{*})italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) to estimate the minimum value of cross-entropy. Unfortunately, most of the empirical estimators to be used when ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT is known through samples suffer in high dimension[ao2023entropy]. Solving (2.11) is equivalent to maximum likelihood method, a widely used practice in parametric statistics[stigler2007epic].
The use of cross-entropy avoids the very problematic computation of H(ρ)𝐻subscript𝜌H(\rho_{*})italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ), but in 2.10 the estimation of Zθsubscript𝑍𝜃Z_{\theta}italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is also needed. However, the most common routines for cross-entropy minimization are gradient-based: they rely on the gradient of θH(ρ,ρθ)subscript𝜃𝐻subscript𝜌subscript𝜌𝜃\partial_{\theta}H(\rho_{*},\rho_{\theta})∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) and not on the cross-entropy itself. The former can be computed using the identity θlogZθ=dθUθ(x)ρθ(x)dxsubscript𝜃subscript𝑍𝜃subscriptsuperscript𝑑subscript𝜃subscript𝑈𝜃𝑥subscript𝜌𝜃𝑥𝑑𝑥\partial_{\theta}\log Z_{\theta}=-\int_{\mathbb{R}^{d}}\partial_{\theta}U_{% \theta}(x)\rho_{\theta}(x)dx∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x, obtaining

θH(ρ,ρθ)subscript𝜃𝐻subscript𝜌subscript𝜌𝜃\displaystyle\partial_{\theta}H(\rho_{*},\rho_{\theta})∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) =dθUθ(x)ρ(x)dxdθUθ(x)ρθ(x)dxabsentsubscriptsuperscript𝑑subscript𝜃subscript𝑈𝜃𝑥subscript𝜌𝑥𝑑𝑥subscriptsuperscript𝑑subscript𝜃subscript𝑈𝜃𝑥subscript𝜌𝜃𝑥𝑑𝑥\displaystyle=\int_{\mathbb{R}^{d}}\partial_{\theta}U_{\theta}(x)\rho_{*}(x)dx% -\int_{\mathbb{R}^{d}}\partial_{\theta}U_{\theta}(x)\rho_{\theta}(x)dx= ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x (2.12)
𝔼[θUθ]𝔼θ[θUθ].absentsubscript𝔼delimited-[]subscript𝜃subscript𝑈𝜃subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃\displaystyle\coloneqq\mathbb{E}_{*}[\partial_{\theta}U_{\theta}]-\mathbb{E}_{% \theta}[\partial_{\theta}U_{\theta}].≔ blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] - blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] .

This is a crucial expression for the present work, and the consequence is immediate:

Remark 2.2 (Fundamental problem for EBM training).

Estimating θH(ρ,ρθ)subscript𝜃𝐻subscript𝜌subscript𝜌𝜃\partial_{\theta}H(\rho_{*},\rho_{\theta})∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) requires calculating the expectation 𝔼θ[θUθ]subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃\mathbb{E}_{\theta}[\partial_{\theta}U_{\theta}]blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ]. In contrast 𝔼[θUθ]subscript𝔼delimited-[]subscript𝜃subscript𝑈𝜃\mathbb{E}_{*}[\partial_{\theta}U_{\theta}]blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] can be readily estimated on the data.

Typical training methods, e.g. based on the so-called Constrastive Divergence[hinton2002training] and its specifications (see Subsection 6), resort to various approximations to calculate the expectation 𝔼θ[θUθ]subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃\mathbb{E}_{\theta}[\partial_{\theta}U_{\theta}]blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ]. While these approaches have proven successful in many situations, they are prone to training instabilities that limit their applicability. The cross-entropy is more stringent, and therefore better, than objectives like the Fisher divergence used to train other generative models: for example, unlike the latter, it is sensitive to the relative probability weights of modes on ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT separated by low-density regions [song2021train].

3 EBMs among generative models

In this section, our objective is to provide a brief overview of the other main generative models available on the market, possibly in relation to Energy-Based Models. The aim is to construct a convenient general framework for the reader, with detailed specifications not being the focus of this section. Let us establish a general classification of the methods we will discuss. As outlined in the introduction, creating a generative model involves developing a computational tool capable of generating new instances representative of a given dataset. Taking the example of image generation, starting with a dataset of dogs, a generative model can produce new images of dogs. Even in this simple example, determining whether a generated sample is "good" or not can be far from obvious. A good generative model should possess two key properties: (1) ease of training and (2) ease of generation. Unfortunately, demanding the best of all possible worlds is often impractical, and a trade-off is frequently necessary to balance these two properties.
The concept of a generative model is relatively new and strictly related to the rise of Big Data. Before the advent of modern computer science, generating data (for inference, modeling) was identified with collecting measures. The advent of computer simulations laid the first stone towards generating data from a model. Let us mention Fermi-Pasta-Ulam-Tsingou[fermi1955studies], which is usually referred to as one of the first uses of computers to simulate a physical model. In statistics, this concept of generating data from a given model is called "sampling" (see Section 4). The change of paradigm towards generating data from data became possible when sufficient computational power and memory were available. Generative AI is following a path similar to the internet: originally limited to academic purposes[arpa], it now permeates everyday life. Thanks, for instance, to Generative Pre-Trained Transformers (such as ChatGPT[gene3]), we seem to be closer to creating a machine capable of generating data, text, sounds, and more, as humans do. The debate about artificial general intelligence capable of surpassing humans is already spreading[morozov2023true, fjelland2020general, federspiel2023threats].
We will now review the technical details of state-of-the-art generative models. At the end, we will also highlight the relation with Energy-Based Models if applicable.

3.1 Variational Autoencoders

As we can infer from the name, to present a variational autoencoder (VAE)[girin2020dynamical] we firstly need to summarize what an autoencoder (AE) is[hinton2006reducing]. Let us focus on Figure 2: it is a Deep Neural Network (DNN) designed to replicate an input vector xd𝑥superscript𝑑x\in\mathbb{R}^{d}italic_x ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, after the application of two NN in sequence. The left segment of the AE, known as the encoder e(x)𝑒𝑥e(x)italic_e ( italic_x ), generates a low-dimensional latent representation zL𝑧superscript𝐿z\in\mathbb{R}^{L}italic_z ∈ blackboard_R start_POSTSUPERSCRIPT italic_L end_POSTSUPERSCRIPT, with Ld𝐿𝑑L\leq ditalic_L ≤ italic_d, at the bottleneck layer. The right segment, referred to as the decoder d(z)𝑑𝑧d(z)italic_d ( italic_z ), endeavors to reconstruct x𝑥xitalic_x from z𝑧zitalic_z. During the training phase, the true output is compared with d(e(x))𝑑𝑒𝑥d(e(x))italic_d ( italic_e ( italic_x ) ) in order to perform backpropagation and train the nets. During the test phase, x^^𝑥\hat{x}over^ start_ARG italic_x end_ARG is used as an estimated value of x𝑥xitalic_x, that is x^x^𝑥𝑥\hat{x}\approx xover^ start_ARG italic_x end_ARG ≈ italic_x.

Refer to caption
Figure 2: Representation of an autoencoder, taken from [vae]

An AE can be seen as a trainable compression protocol: once trained, encoder and decoder are separate parts that can be used separately, for instance before and after a data transmission procedure. In practice, their use is widely diffused in Machine Learning application: it is common to put extra layers acting in the latent space, for instance for a supervised tasks[bank2023autoencoders]. Up to this point, everything operates deterministically: during testing, when the AE is provided with a specific input vector, it consistently produces the corresponding output.
The subsequent specification of AE are the Variational Autoencoders[DBLP:journals/corr/KingmaW13]. While in AE we had two deterministic functions e(x)𝑒𝑥e(x)italic_e ( italic_x ) and d(z)𝑑𝑧d(z)italic_d ( italic_z ), in VAE encoder and decoder are two probabilistic models: an inference model and a generative model. Despite this classification, VAE are usually referred to as generative models in toto. Let us clarify in formulae the construction.
We consider the joint parametric probability density ρθ(x,z)subscript𝜌𝜃𝑥𝑧\rho_{\theta}(x,z)italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_z ) on d×Lsuperscript𝑑superscript𝐿\mathbb{R}^{d}\times\mathbb{R}^{L}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT × blackboard_R start_POSTSUPERSCRIPT italic_L end_POSTSUPERSCRIPT, where the parameters θΘ𝜃Θ\theta\in\Thetaitalic_θ ∈ roman_Θ are the weights of a neural network (NN). Specifically, using the definition of joint PDF, we write

ρθ(x,z)=ρθ(x|z)ρ(z)subscript𝜌𝜃𝑥𝑧subscript𝜌𝜃conditional𝑥𝑧𝜌𝑧\rho_{\theta}(x,z)=\rho_{\theta}(x|z)\rho(z)italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_z ) = italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x | italic_z ) italic_ρ ( italic_z ) (3.1)

The prior distribution ρ(z)𝜌𝑧\rho(z)italic_ρ ( italic_z ) is usually assumed to be a multivariate gaussian distribution 𝒩(z,𝟎L,𝑰L)𝒩𝑧subscript0𝐿subscript𝑰𝐿\mathcal{N}(z,\boldsymbol{0}_{L},\boldsymbol{I}_{L})caligraphic_N ( italic_z , bold_0 start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT , bold_italic_I start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT ), with zero mean vector 𝟎Lsubscript0𝐿\boldsymbol{0}_{L}bold_0 start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT and identity 𝑰Lsubscript𝑰𝐿\boldsymbol{I}_{L}bold_italic_I start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT as covariance. The parametric conditional PDF ρθ(x|z)subscript𝜌𝜃conditional𝑥𝑧\rho_{\theta}(x|z)italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x | italic_z ) is the decoder network and can be designed case by case: the simplest and traditional choice is a gaussian

ρθ(x|z)=𝒩(x,𝝁θ(z),diag{𝝈θ2(z)})subscript𝜌𝜃conditional𝑥𝑧𝒩𝑥subscript𝝁𝜃𝑧diagsubscriptsuperscript𝝈2𝜃𝑧\rho_{\theta}(x|z)=\mathcal{N}(x,\boldsymbol{\mu}_{\theta}(z),\operatorname{% diag}\{\boldsymbol{\sigma}^{2}_{\theta}(z)\})italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x | italic_z ) = caligraphic_N ( italic_x , bold_italic_μ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z ) , roman_diag { bold_italic_σ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z ) } ) (3.2)

with parametric mean 𝝁θ(z)subscript𝝁𝜃𝑧\boldsymbol{\mu}_{\theta}(z)bold_italic_μ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z ) and diagonal covariance matrix diag{𝝈θ2(z)}diagsubscriptsuperscript𝝈2𝜃𝑧\operatorname{diag}\{\boldsymbol{\sigma}^{2}_{\theta}(z)\}roman_diag { bold_italic_σ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z ) } (for instance modelled through appropriate NN). Other possibilities have been studied to tackle different kind of data, for instance audio[girin2019notes].
Following this formal definition, the marginal distribution of the data x𝑥xitalic_x will be

ρθ(x)=Lρθ(x|z)ρ(z)𝑑zsubscript𝜌𝜃𝑥subscriptsuperscript𝐿subscript𝜌𝜃conditional𝑥𝑧𝜌𝑧differential-d𝑧\rho_{\theta}(x)=\int_{\mathbb{R}^{L}}\rho_{\theta}(x|z)\rho(z)dzitalic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_L end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x | italic_z ) italic_ρ ( italic_z ) italic_d italic_z (3.3)

Similarly to EBM training, we need to select the optimal parameters θsuperscript𝜃\theta^{*}italic_θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT that minimize a selected measure of discrepancy between the model and the true data distribution ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, as usual known just through samples. The procedure is analogous to (2.11): KL divergence is used to evaluate this diversity,

θ=argminθΘDKL(ρ(x)ρθ(x))=argmaxθΘ𝔼[logρθ(x)]superscript𝜃subscriptargmin𝜃Θsubscript𝐷KLconditionalsubscript𝜌𝑥subscript𝜌𝜃𝑥subscriptargmax𝜃Θsubscript𝔼delimited-[]subscript𝜌𝜃𝑥\theta^{*}=\operatorname*{arg\,min}_{\theta\in\Theta}D_{\text{KL}}(\rho_{*}(x)% \parallel\rho_{\theta}(x))=\operatorname*{arg\,max}_{\theta\in\Theta}\mathbb{E% }_{*}[\log\rho_{\theta}(x)]italic_θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT = start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) ∥ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ) = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ] (3.4)

Differently from EBMs, the right-hand side is traditionally written as an expectation: it is the marginal log-likelihood of the model[stigler2007epic]. It is just a matter of notation — the optimization objectives are the same. When having a dataset 𝒳={xid}i=1N𝒳superscriptsubscriptsubscript𝑥𝑖superscript𝑑𝑖1𝑁\mathcal{X}=\{x_{i}\in\mathbb{R}^{d}\}_{i=1}^{N}caligraphic_X = { italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT, one could estimate the expectation via the empirical average i=1Nlogρθ(xi)/Nsuperscriptsubscript𝑖1𝑁subscript𝜌𝜃subscript𝑥𝑖𝑁\sum_{i=1}^{N}\log\rho_{\theta}(x_{i})/N∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) / italic_N. However, the log-likelihood is defined via (3.3), and such an integral is often analytically intractable. That is, one has no direct access to logρθ(x)subscript𝜌𝜃𝑥\log\rho_{\theta}(x)roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) explicitly. The proposed solution to overcome this issue is based on a variational approach. Let us present a crucial definition and a lemma:

Definition 3.1 (ELBO).

Let \mathcal{F}caligraphic_F denote a variational family defined as a set of PDFs over the latent variables z𝑧zitalic_z. For any q(z)𝑞𝑧q(z)\in\mathcal{F}italic_q ( italic_z ) ∈ caligraphic_F, the Evidence Lower Bound (ELBO) (also known as variational free energy) :Θ××Rd:Θsuperscript𝑅𝑑\mathcal{L}:\Theta\times\mathcal{F}\times R^{d}\to\mathbb{R}caligraphic_L : roman_Θ × caligraphic_F × italic_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT → blackboard_R is defined as

(θ,q(z);x)=𝔼q(z)[logρθ(x,z)logq(z)]𝜃𝑞𝑧𝑥subscript𝔼𝑞𝑧delimited-[]subscript𝜌𝜃𝑥𝑧𝑞𝑧\mathcal{L}(\theta,q(z);x)=\mathbb{E}_{q(z)}[\log\rho_{\theta}(x,z)-\log q(z)]caligraphic_L ( italic_θ , italic_q ( italic_z ) ; italic_x ) = blackboard_E start_POSTSUBSCRIPT italic_q ( italic_z ) end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_z ) - roman_log italic_q ( italic_z ) ] (3.5)
Lemma 3.1.

The following properties hold true:

  1. 1.

    Decomposition of marginal log-likelihood[neal1998view].

    logρθ=(θ,q(z);x)+DKL(q(z)ρθ(z|x))\log\rho_{\theta}=\mathcal{L}(\theta,q(z);x)+D_{\text{KL}}(q(z)\parallel\rho_{% \theta}(z|x))roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = caligraphic_L ( italic_θ , italic_q ( italic_z ) ; italic_x ) + italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_q ( italic_z ) ∥ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ) ) (3.6)
  2. 2.

    Bound on marginal log-likelihood.

    (θ,q(z);x)logρθ(x)(θ,q(z);x)=logρθ(x)q(z)=ρθ(z|x)iff𝜃𝑞𝑧𝑥subscript𝜌𝜃𝑥𝜃𝑞𝑧𝑥subscript𝜌𝜃𝑥𝑞𝑧subscript𝜌𝜃conditional𝑧𝑥\begin{split}\mathcal{L}(\theta,q(z);x)&\leq\log\rho_{\theta}(x)\\ \mathcal{L}(\theta,q(z);x)&=\log\rho_{\theta}(x)\iff q(z)=\rho_{\theta}(z|x)% \end{split}start_ROW start_CELL caligraphic_L ( italic_θ , italic_q ( italic_z ) ; italic_x ) end_CELL start_CELL ≤ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) end_CELL end_ROW start_ROW start_CELL caligraphic_L ( italic_θ , italic_q ( italic_z ) ; italic_x ) end_CELL start_CELL = roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ⇔ italic_q ( italic_z ) = italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ) end_CELL end_ROW (3.7)
Proof.

The proof of (1) is trivial:

(θ,q(z);x)+DKL(q(z)ρθ(z|x))=𝔼q(z)[logρθ(x,z)logq(z)]\displaystyle\mathcal{L}(\theta,q(z);x)+D_{\text{KL}}(q(z)\parallel\rho_{% \theta}(z|x))=\mathbb{E}_{q(z)}[\log\rho_{\theta}(x,z)-\log q(z)]caligraphic_L ( italic_θ , italic_q ( italic_z ) ; italic_x ) + italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_q ( italic_z ) ∥ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ) ) = blackboard_E start_POSTSUBSCRIPT italic_q ( italic_z ) end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_z ) - roman_log italic_q ( italic_z ) ] (3.8)
+𝔼q(z)[logq(z)logρθ(z|x)]=𝔼q(z)[log(ρθ(x,z)ρθ(z|x))]=logρθ(x)subscript𝔼𝑞𝑧delimited-[]𝑞𝑧subscript𝜌𝜃conditional𝑧𝑥subscript𝔼𝑞𝑧delimited-[]subscript𝜌𝜃𝑥𝑧subscript𝜌𝜃conditional𝑧𝑥subscript𝜌𝜃𝑥\displaystyle+\mathbb{E}_{q(z)}[\log q(z)-\log\rho_{\theta}(z|x)]=\mathbb{E}_{% q(z)}\left[\log\left(\frac{\rho_{\theta}(x,z)}{\rho_{\theta}(z|x)}\right)% \right]=\log\rho_{\theta}(x)+ blackboard_E start_POSTSUBSCRIPT italic_q ( italic_z ) end_POSTSUBSCRIPT [ roman_log italic_q ( italic_z ) - roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ) ] = blackboard_E start_POSTSUBSCRIPT italic_q ( italic_z ) end_POSTSUBSCRIPT [ roman_log ( divide start_ARG italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_z ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ) end_ARG ) ] = roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x )

where we used the definition of conditional probability and the fact that the expectation is computed in the latent space. (2) is a direct consequence of (3.6) since the KL divergence is non-negative and identically zero just when q(z)=ρθ(z|x)𝑞𝑧subscript𝜌𝜃conditional𝑧𝑥q(z)=\rho_{\theta}(z|x)italic_q ( italic_z ) = italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ). ∎

Thanks to such results, an estimate of the log-likelihood can be obtained using the Expectation-Maximization (EM) algorithm[dempster1977maximum]: (E) step corresponds to solve the unconstrained variational problem at fixed θ𝜃\thetaitalic_θ

q(z)=argmaxq(θ,q(z);x)subscript𝑞𝑧subscriptargmax𝑞𝜃𝑞𝑧𝑥q_{*}(z)=\operatorname*{arg\,max}_{q\in\mathcal{F}}\mathcal{L}(\theta,q(z);x)italic_q start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_z ) = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_q ∈ caligraphic_F end_POSTSUBSCRIPT caligraphic_L ( italic_θ , italic_q ( italic_z ) ; italic_x ) (3.9)

while (M) step to maximization of ELBO w.r.t. θ𝜃\thetaitalic_θ at fixed q(z)𝑞𝑧q(z)italic_q ( italic_z ). To be precise, the output of the (E) steps is conditioned on x𝑥xitalic_x, which is q(z)=q(z|x)𝑞𝑧𝑞conditional𝑧𝑥q(z)=q(z|x)italic_q ( italic_z ) = italic_q ( italic_z | italic_x ). It can be theoretically proven that under suitable condition such an algorithm converges to the optimum and satisfies the equality in (3.7).
For now there is no evident advantage: solving an explicit variational optimization problem can be unfeasible as the computation of (3.3). But further simplifications are possible: in so-called fixed-form variational inference[honkela2010approximate], the variational family \mathcal{F}caligraphic_F is constrained to be any parametric family of PDFs qλ(z|x)subscript𝑞𝜆conditional𝑧𝑥q_{\lambda}(z|x)italic_q start_POSTSUBSCRIPT italic_λ end_POSTSUBSCRIPT ( italic_z | italic_x ) dependent on λΛ𝜆Λ\lambda\in\Lambdaitalic_λ ∈ roman_Λ; e.g. for the gaussian family qλ(z|x)=𝒩(z;𝝁,𝚺)subscript𝑞𝜆conditional𝑧𝑥𝒩𝑧𝝁𝚺q_{\lambda}(z|x)=\mathcal{N}(z;\boldsymbol{\mu},\boldsymbol{\Sigma})italic_q start_POSTSUBSCRIPT italic_λ end_POSTSUBSCRIPT ( italic_z | italic_x ) = caligraphic_N ( italic_z ; bold_italic_μ , bold_Σ ) we have λ={𝝁,𝚺}𝜆𝝁𝚺\lambda=\{\boldsymbol{\mu},\boldsymbol{\Sigma}\}italic_λ = { bold_italic_μ , bold_Σ }. The advantage is that one can perform the (E) step as optimizing λ𝜆\lambdaitalic_λ and not in a function class, and possibly find

λ=argmaxλ(θ,λ;x)superscript𝜆subscriptargmax𝜆𝜃𝜆𝑥\lambda^{*}=\operatorname*{arg\,max}_{\lambda}\mathcal{L}(\theta,\lambda;x)italic_λ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_λ end_POSTSUBSCRIPT caligraphic_L ( italic_θ , italic_λ ; italic_x ) (3.10)

Since we have to deal with a dataset of N𝑁Nitalic_N data point, we rewrite

(θ,λ;𝒳)=i=1N(θ,λi;xi)𝜃𝜆𝒳superscriptsubscript𝑖1𝑁𝜃subscript𝜆𝑖subscript𝑥𝑖\mathcal{L}(\theta,\lambda;\mathcal{X})=\sum_{i=1}^{N}\mathcal{L}(\theta,% \lambda_{i};x_{i})caligraphic_L ( italic_θ , italic_λ ; caligraphic_X ) = ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT caligraphic_L ( italic_θ , italic_λ start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ; italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) (3.11)

and ideally perform gradient-based optimization routines both in (E) and (M) step. But we immediately notice that optimizing the "local" λisubscript𝜆𝑖\lambda_{i}italic_λ start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT for each sample if N𝑁Nitalic_N is big is very impractical: for instance, for the gaussian class in dimension d𝑑ditalic_d we should update N𝑁Nitalic_N means and covariance matrices, that is Nd2(d+1)/2𝑁superscript𝑑2𝑑12Nd^{2}(d+1)/2italic_N italic_d start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ( italic_d + 1 ) / 2 scalars.
Thus, a last assumption is necessary to practically train the generative model, leading to the so-called amortized variational inference. It corresponds to assume that there exists a parametric map fϕsubscript𝑓italic-ϕf_{\phi}italic_f start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT such that λi=fϕ(xi)subscript𝜆𝑖subscript𝑓italic-ϕsubscript𝑥𝑖\lambda_{i}=f_{\phi}(x_{i})italic_λ start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_f start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ). In this way, the definitive learning objective for EM algorithm is

(θ,λ;𝒳)=i=1N(θ,ϕ;xi)=i=1N𝔼qϕ(zi|xi)[logρθ(xi,zi)logqϕ(zi|xi)]𝜃𝜆𝒳superscriptsubscript𝑖1𝑁𝜃italic-ϕsubscript𝑥𝑖superscriptsubscript𝑖1𝑁subscript𝔼subscript𝑞italic-ϕconditionalsubscript𝑧𝑖subscript𝑥𝑖delimited-[]subscript𝜌𝜃subscript𝑥𝑖subscript𝑧𝑖subscript𝑞italic-ϕconditionalsubscript𝑧𝑖subscript𝑥𝑖\mathcal{L}(\theta,\lambda;\mathcal{X})=\sum_{i=1}^{N}\mathcal{L}(\theta,\phi;% x_{i})=\sum_{i=1}^{N}\mathbb{E}_{q_{\phi}(z_{i}|x_{i})}[\log\rho_{\theta}(x_{i% },z_{i})-\log q_{\phi}(z_{i}|x_{i})]caligraphic_L ( italic_θ , italic_λ ; caligraphic_X ) = ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT caligraphic_L ( italic_θ , italic_ϕ ; italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) = ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT blackboard_E start_POSTSUBSCRIPT italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT , italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) - roman_log italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ] (3.12)

Summarizing this first part, we started from the problem of training the decoder network ρθ(x|z)subscript𝜌𝜃conditional𝑥𝑧\rho_{\theta}(x|z)italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x | italic_z ) and we had to face the issue of computing the marginal log-likelihood. Thanks to a reformulation of the problem, we could explicit an equivalent objective (3.12). Given qϕ(z|x)subscript𝑞italic-ϕconditional𝑧𝑥q_{\phi}(z|x)italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z | italic_x ), that is the approximation of the intractable posterior ρθ(z|x)subscript𝜌𝜃conditional𝑧𝑥\rho_{\theta}(z|x)italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z | italic_x ), (θ,λ;x)𝜃𝜆𝑥\mathcal{L}(\theta,\lambda;x)caligraphic_L ( italic_θ , italic_λ ; italic_x ) can be attacked via EM algorithm, i.e. alternatively optimizing θ𝜃\thetaitalic_θ and ϕitalic-ϕ\phiitalic_ϕ.
VAE approach can be seen as a particular case of amortized variational inference in which qϕ(z|x)subscript𝑞italic-ϕconditional𝑧𝑥q_{\phi}(z|x)italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z | italic_x ) is approximated via a neural network, which by analogy with AE is denoted as encoder network. Similarly to the decoder network, a widely used choice is a gaussian, i.e.

ρϕ(z|x)=𝒩(z,𝝁ϕ(x),diag{𝝈ϕ2(x)})subscript𝜌italic-ϕconditional𝑧𝑥𝒩𝑧subscript𝝁italic-ϕ𝑥diagsubscriptsuperscript𝝈2italic-ϕ𝑥\rho_{\phi}(z|x)=\mathcal{N}(z,\boldsymbol{\mu}_{\phi}(x),\operatorname{diag}% \{\boldsymbol{\sigma}^{2}_{\phi}(x)\})italic_ρ start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z | italic_x ) = caligraphic_N ( italic_z , bold_italic_μ start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_x ) , roman_diag { bold_italic_σ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_x ) } ) (3.13)

where mean and covariance are modelled by a NN. The proposal to train a VAE[DBLP:journals/corr/KingmaW13] is to perform gradient-based optimization on the joint set of parameters {θ,ϕ}𝜃italic-ϕ\{\theta,\phi\}{ italic_θ , italic_ϕ } with (3.12) as objective. Since the encoder and decoder are in cascade, the joint training can be suboptimal[he2018lagging] with respect to the alternating routine in EM algorithm.
Despite this drawback, using the definition of KL divergence and conditional probability, we rewrite (3.12) as

(θ,λ;𝒳)=i=1N𝔼qϕ(zi|xi)[logρθ(xi|zi)]i=1NDKL[qϕ(zi|xi)ρ(z)]𝜃𝜆𝒳superscriptsubscript𝑖1𝑁subscript𝔼subscript𝑞italic-ϕconditionalsubscript𝑧𝑖subscript𝑥𝑖delimited-[]subscript𝜌𝜃conditionalsubscript𝑥𝑖subscript𝑧𝑖superscriptsubscript𝑖1𝑁subscript𝐷KLdelimited-[]conditionalsubscript𝑞italic-ϕconditionalsubscript𝑧𝑖subscript𝑥𝑖𝜌𝑧\mathcal{L}(\theta,\lambda;\mathcal{X})=\sum_{i=1}^{N}\mathbb{E}_{q_{\phi}(z_{% i}|x_{i})}[\log\rho_{\theta}(x_{i}|z_{i})]-\sum_{i=1}^{N}D_{\text{KL}}[q_{\phi% }(z_{i}|x_{i})\parallel\rho(z)]caligraphic_L ( italic_θ , italic_λ ; caligraphic_X ) = ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT blackboard_E start_POSTSUBSCRIPT italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ] - ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT [ italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ∥ italic_ρ ( italic_z ) ] (3.14)

The two summations can be easily interpreted: the first one is related to reconstruction accuracy and measures the fidelity of encoding and decoding chain; the second one is a regularization term that forces the posterior (encoder) to be close to the prior, which is a set of independent gaussians — ideally, each z𝑧zitalic_z entry should encode an independent characteristic of the data.
Regarding the actual implementation of a gradient routine, the whole point of ELBO reformulation was the intractability of the marginal likelihood. Thus, we have to ensure to not have the same issue for \mathcal{L}caligraphic_L. The regularization term has an analytical expression for the usual mentioned choices for qϕ(z|x)subscript𝑞italic-ϕconditional𝑧𝑥q_{\phi}(z|x)italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z | italic_x ) and ρ(z)𝜌𝑧\rho(z)italic_ρ ( italic_z ) (e.g. if it is the KL divergence between gaussian densities). Thus, the computation of the gradient of that summation w.r.t. to θ𝜃\thetaitalic_θ or ϕitalic-ϕ\phiitalic_ϕ is not a problem for backpropagation algorithm (n.b. we are dealing with NN). On the other hand, the first summation in analytically intractable: the only possibility is the use of a Monte Carlo estimate using samples {z(r)i}r=1Rsuperscriptsubscriptsuperscript𝑧subscript𝑟𝑖𝑟1𝑅\{z^{(r)_{i}}\}_{r=1}^{R}{ italic_z start_POSTSUPERSCRIPT ( italic_r ) start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_r = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_R end_POSTSUPERSCRIPT drawn from qϕ(zi|xi)subscript𝑞italic-ϕconditionalsubscript𝑧𝑖subscript𝑥𝑖q_{\phi}(z_{i}|x_{i})italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ). Sampling from a gaussian encoder is an easy task, but unfortunately it is not a differentiable operation and it poses an obstacle to perform backpropagation w.r.t. ϕitalic-ϕ\phiitalic_ϕ. The solution to this last issue is the following reparametrization trick:

zi(r)=𝝁ϕ(xi)+diag{𝝈ϕ2(x)}12ϵ(r)ϵ(r)𝒩(𝟎L,𝑰L)z^{(r)}_{i}=\boldsymbol{\mu}_{\phi}(x_{i})+\operatorname{diag}\{\boldsymbol{% \sigma}^{2}_{\phi}(x)\}^{\frac{1}{2}}\epsilon^{(r)}\quad\quad\epsilon^{(r)}% \sim\mathcal{N}(\boldsymbol{0}_{L},\boldsymbol{I}_{L})italic_z start_POSTSUPERSCRIPT ( italic_r ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = bold_italic_μ start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) + roman_diag { bold_italic_σ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_x ) } start_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT italic_ϵ start_POSTSUPERSCRIPT ( italic_r ) end_POSTSUPERSCRIPT italic_ϵ start_POSTSUPERSCRIPT ( italic_r ) end_POSTSUPERSCRIPT ∼ caligraphic_N ( bold_0 start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT , bold_italic_I start_POSTSUBSCRIPT italic_L end_POSTSUBSCRIPT ) (3.15)

which allows to effectively compute the gradient w.r.t. ϕitalic-ϕ\phiitalic_ϕ. The resulting empirical estimate of (θ,λ;𝒳)𝜃𝜆𝒳\mathcal{L}(\theta,\lambda;\mathcal{X})caligraphic_L ( italic_θ , italic_λ ; caligraphic_X ) is

^(θ,λ;𝒳)=i=1N1Ri=rRlogρθ(xi|zi(r))i=1NDKL[qϕ(zi|xi)ρ(z)],^𝜃𝜆𝒳superscriptsubscript𝑖1𝑁1𝑅superscriptsubscript𝑖𝑟𝑅subscript𝜌𝜃conditionalsubscript𝑥𝑖superscriptsubscript𝑧𝑖𝑟superscriptsubscript𝑖1𝑁subscript𝐷KLdelimited-[]conditionalsubscript𝑞italic-ϕconditionalsubscript𝑧𝑖subscript𝑥𝑖𝜌𝑧\hat{\mathcal{L}}(\theta,\lambda;\mathcal{X})=\sum_{i=1}^{N}\frac{1}{R}\sum_{i% =r}^{R}\log\rho_{\theta}(x_{i}|z_{i}^{(r)})-\sum_{i=1}^{N}D_{\text{KL}}[q_{% \phi}(z_{i}|x_{i})\parallel\rho(z)],over^ start_ARG caligraphic_L end_ARG ( italic_θ , italic_λ ; caligraphic_X ) = ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG italic_R end_ARG ∑ start_POSTSUBSCRIPT italic_i = italic_r end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_R end_POSTSUPERSCRIPT roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( italic_r ) end_POSTSUPERSCRIPT ) - ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT [ italic_q start_POSTSUBSCRIPT italic_ϕ end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ∥ italic_ρ ( italic_z ) ] , (3.16)

which is the objective for the joint optimization of θ𝜃\thetaitalic_θ and ϕitalic-ϕ\phiitalic_ϕ.
After some manipulation, we conclude that VAEs can be trained on log-likelihood objective. The main strength appears to be the ease of generation, since for common choices of encoder and decoder such task reduces to sample from a gaussian distribution. In fact, the main drawbacks[wei2020variations, oussidi2018deep, sengupta2020review] of VAEs lays in the training phase. First of all, VAEs have several hyperparameters (e.g., the choice of prior, a possible imbalanced weighting of the reconstruction and regularization terms) that can significantly impact their performance. Finding the optimal set of hyperparameters can be a challenging task. The assumed simple structure of the latent space in VAEs might not capture the complex dependencies present in the data, limiting the expressiveness of the learned representations. Plus, achieving perfect disentanglement remains a challenge. The latent variables might still be entangled, making it challenging to control specific factors independently. Empirically, it is observed that VAEs sometimes generate blurry samples or suffer from mode collapse, where the model focuses on capturing only a few modes of the data distribution, neglecting others. In general it seems to be an issue related to their limited capacity: they might struggle with capturing complex and high-dimensional data distributions effectively, especially when compared to other generative models.

3.2 Generative Adversarial Networks

Generative adversarial networks[goodfellow2014generative] (GANs) are a class of generative models which take inspiration from game theory. They consist of two neural networks (see Figure 3), namely a generator G and a discriminator D, trained simultaneously through the so-called adversarial training. Given a dataset 𝒳𝒳\mathcal{X}caligraphic_X sampled from the unknown data distribution ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, the generator is devoted to generate synthetic data that ideally resembles the training data. On the other hand, the discriminator has to discern between fake and true samples. In this sense, G and D are adversary: the generator aims to produce realistic data to fool the discriminator, while the discriminator strives to correctly classify real and fake data. Thus, the training ends when the discriminator becomes unable to effectively distinguish between real and generated samples.

Refer to caption
Figure 3: Scheme of the structure of GANs, taken from [gans].

Let us present the mathematical formulation: firstly we define a prior ρz(z)subscript𝜌𝑧𝑧\rho_{z}(z)italic_ρ start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT ( italic_z ), which is a PDF easy to sample from that serve to inject noise into the generator. The latter is a function Gθg(z)subscript𝐺subscript𝜃𝑔𝑧G_{\theta_{g}}(z)italic_G start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_z ) that is fed with noise and generate "fake" samples that should be similar to samples from ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. The discriminator is a parametric function Dθd(x)subscript𝐷subscript𝜃𝑑𝑥D_{\theta_{d}}(x)italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x ) that gives the probability that a sample x𝑥xitalic_x comes from the training set rather than have been generated by G𝐺Gitalic_G. Both θgsubscript𝜃𝑔\theta_{g}italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT and θdsubscript𝜃𝑑\theta_{d}italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT are parameters of a NN. The optimal weights are solution of the following two-player minimax problem:

argminθgargmaxθd𝔼[logDθd(x)]+𝔼ρz[log(1Dθd(Gθg(z)))]argminθgargmaxθdV(G,D)subscriptargminsubscript𝜃𝑔subscriptargmaxsubscript𝜃𝑑subscript𝔼delimited-[]subscript𝐷subscript𝜃𝑑𝑥subscript𝔼subscript𝜌𝑧delimited-[]1subscript𝐷subscript𝜃𝑑subscript𝐺subscript𝜃𝑔𝑧subscriptargminsubscript𝜃𝑔subscriptargmaxsubscript𝜃𝑑𝑉𝐺𝐷\operatorname*{arg\,min}_{\theta_{g}}\operatorname*{arg\,max}_{\theta_{d}}% \mathbb{E}_{*}[\log D_{\theta_{d}}(x)]+\mathbb{E}_{\rho_{z}}[\log(1-D_{\theta_% {d}}(G_{\theta_{g}}(z)))]\coloneqq\operatorname*{arg\,min}_{\theta_{g}}% \operatorname*{arg\,max}_{\theta_{d}}V(G,D)start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x ) ] + blackboard_E start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT end_POSTSUBSCRIPT [ roman_log ( 1 - italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_G start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_z ) ) ) ] ≔ start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT italic_V ( italic_G , italic_D ) (3.17)

We refer in the following to ρg(x)subscript𝜌𝑔𝑥\rho_{g}(x)italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) as the distribution of "fake" samples induced by the generator, that is such that

𝔼ρz[log(1Dθd(Gθg(z)))]=𝔼ρg[log(1Dθd(x))]subscript𝔼subscript𝜌𝑧delimited-[]1subscript𝐷subscript𝜃𝑑subscript𝐺subscript𝜃𝑔𝑧subscript𝔼subscript𝜌𝑔delimited-[]1subscript𝐷subscript𝜃𝑑𝑥\mathbb{E}_{\rho_{z}}[\log(1-D_{\theta_{d}}(G_{\theta_{g}}(z)))]=\mathbb{E}_{% \rho_{g}}[\log(1-D_{\theta_{d}}(x))]blackboard_E start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT end_POSTSUBSCRIPT [ roman_log ( 1 - italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_G start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_z ) ) ) ] = blackboard_E start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT [ roman_log ( 1 - italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x ) ) ] (3.18)

The empirical idea to solve the minimax game is via an alternating algorithm:

Proposition 3.1.

The optimization algorithm for a GAN is made by two alternating steps:

  • Update of the discriminator

    1. 1.

      Sample {z(i)}i=1Nsuperscriptsubscriptsuperscript𝑧𝑖𝑖1𝑁\{z^{(i)}\}_{i=1}^{N}{ italic_z start_POSTSUPERSCRIPT ( italic_i ) end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT (noise) from ρzsubscript𝜌𝑧\rho_{z}italic_ρ start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT and {x(i)}i=1Nsuperscriptsubscriptsuperscript𝑥𝑖𝑖1𝑁\{x^{(i)}\}_{i=1}^{N}{ italic_x start_POSTSUPERSCRIPT ( italic_i ) end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT (data) from ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT.

    2. 2.

      Compute θdV(G,D)subscriptsubscript𝜃𝑑𝑉𝐺𝐷\nabla_{\theta_{d}}V(G,D)∇ start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT italic_V ( italic_G , italic_D ) and perform gradient ascent to update θdsubscript𝜃𝑑\theta_{d}italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT.

  • Update of the generator

    1. 1.

      Sample {z(i)}i=1Nsuperscriptsubscriptsuperscript𝑧𝑖𝑖1𝑁\{z^{(i)}\}_{i=1}^{N}{ italic_z start_POSTSUPERSCRIPT ( italic_i ) end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT (noise) from ρzsubscript𝜌𝑧\rho_{z}italic_ρ start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT.

    2. 2.

      Compute θgV(G,D)subscriptsubscript𝜃𝑔𝑉𝐺𝐷\nabla_{\theta_{g}}V(G,D)∇ start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT italic_V ( italic_G , italic_D ) and perform gradient descent to update θgsubscript𝜃𝑔\theta_{g}italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT.

This proposal is driven by common sense, but a more careful analysis of the minimax game is necessary to ensure convergence of such algorithm. In order to characterize the solutions of this adversarial game, it is necessary to search for the optima. The method of proof is: (1) classify solutions of optimization of D𝐷Ditalic_D at fixed G𝐺Gitalic_G and viceversa and then (2) present a convergence result of the alternating game. Let us start from the update of the discriminator:

Theorem 3.1 (Existence of optimal discriminator[goodfellow2014generative]).

For G𝐺Gitalic_G fixed, the optimal discriminator D𝐷Ditalic_D is

DG=ρ(x)ρ(x)+ρg(x)subscriptsuperscript𝐷𝐺subscript𝜌𝑥subscript𝜌𝑥subscript𝜌𝑔𝑥D^{*}_{G}=\frac{\rho_{*}(x)}{\rho_{*}(x)+\rho_{g}(x)}italic_D start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT = divide start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) + italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) end_ARG (3.19)
Proof.

Using (3.17) and (3.18), we have

V(G,D)=Ω(ρ(x)logDθd(x)+ρg(x)(1Dθd(x)))𝑑x𝑉𝐺𝐷subscriptΩsubscript𝜌𝑥subscript𝐷subscript𝜃𝑑𝑥subscript𝜌𝑔𝑥1subscript𝐷subscript𝜃𝑑𝑥differential-d𝑥V(G,D)=\int_{\Omega}(\rho_{*}(x)\log D_{\theta_{d}}(x)+\rho_{g}(x)(1-D_{\theta% _{d}}(x)))dxitalic_V ( italic_G , italic_D ) = ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) roman_log italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x ) + italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) ( 1 - italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x ) ) ) italic_d italic_x (3.20)

The function yalog(y)+blog(1y)𝑦𝑎𝑦𝑏1𝑦y\to a\log(y)+b\log(1-y)italic_y → italic_a roman_log ( italic_y ) + italic_b roman_log ( 1 - italic_y ) achieve its maximum in (0,1)01(0,1)( 0 , 1 ) at a/(a+b)𝑎𝑎𝑏a/(a+b)italic_a / ( italic_a + italic_b ) for (a,b)(0,0)𝑎𝑏00(a,b)\neq(0,0)( italic_a , italic_b ) ≠ ( 0 , 0 ). Applied to the case in study, the discriminator can be defined just in Supp(ρ(x))Supp(ρg(x))𝑆𝑢𝑝𝑝subscript𝜌𝑥𝑆𝑢𝑝𝑝subscript𝜌𝑔𝑥Supp(\rho_{*}(x))\cup Supp(\rho_{g}(x))italic_S italic_u italic_p italic_p ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) ) ∪ italic_S italic_u italic_p italic_p ( italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) ), hence concluding the proof. ∎

This lemma ensure that the gradient ascending will eventually reach a maximum, that is

C(G)=argmaxDV(G,D)=𝔼[ρ(x)ρ(x)+ρg(x)]+𝔼ρg[ρg(x)ρ(x)+ρg(x)]𝐶𝐺subscriptargmax𝐷𝑉𝐺𝐷subscript𝔼delimited-[]subscript𝜌𝑥subscript𝜌𝑥subscript𝜌𝑔𝑥subscript𝔼subscript𝜌𝑔delimited-[]subscript𝜌𝑔𝑥subscript𝜌𝑥subscript𝜌𝑔𝑥C(G)=\operatorname*{arg\,max}_{D}V(G,D)=\mathbb{E}_{*}\left[\frac{\rho_{*}(x)}% {\rho_{*}(x)+\rho_{g}(x)}\right]+\mathbb{E}_{\rho_{g}}\left[\frac{\rho_{g}(x)}% {\rho_{*}(x)+\rho_{g}(x)}\right]italic_C ( italic_G ) = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_D end_POSTSUBSCRIPT italic_V ( italic_G , italic_D ) = blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ divide start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) + italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) end_ARG ] + blackboard_E start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT [ divide start_ARG italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) + italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ( italic_x ) end_ARG ] (3.21)

Now we need to characterize the solutions of the minimization problem argminGC(G)subscriptargmin𝐺𝐶𝐺\operatorname*{arg\,min}_{G}C(G)start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT italic_C ( italic_G )

Theorem 3.2 (Existence of optimal generator[goodfellow2014generative]).

At fixed D=DG𝐷subscriptsuperscript𝐷𝐺D=D^{*}_{G}italic_D = italic_D start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT, the optimal generator Gsuperscript𝐺G^{*}italic_G start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT induce a ρgsubscript𝜌𝑔\rho_{g}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT such that ρg=ρsubscript𝜌𝑔subscript𝜌\rho_{g}=\rho_{*}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. At that point, C(G)=log4𝐶superscript𝐺4C(G^{*})=-\log 4italic_C ( italic_G start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ) = - roman_log 4.

Proof.

Regarding the last point, for ρg=ρsubscript𝜌𝑔subscript𝜌\rho_{g}=\rho_{*}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT we obtain DG=1/2subscriptsuperscript𝐷𝐺12D^{*}_{G}=1/2italic_D start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT = 1 / 2, that inserted in C(G)𝐶𝐺C(G)italic_C ( italic_G ) gives exactly log44-\log 4- roman_log 4. We need to test whether this is a global optimum: we can sum and subtract log44-\log 4- roman_log 4 to C(G)𝐶𝐺C(G)italic_C ( italic_G ) obtaining

C(G)𝐶𝐺\displaystyle C(G)italic_C ( italic_G ) =log(4)+DKL(ρρ+ρg2)+DKL(ρgρ+ρg2)absent4subscript𝐷𝐾𝐿conditionalsubscript𝜌subscript𝜌subscript𝜌𝑔2subscript𝐷𝐾𝐿conditionalsubscript𝜌𝑔subscript𝜌subscript𝜌𝑔2\displaystyle=-\log(4)+D_{KL}\bigg{(}\rho_{*}\;\bigg{\|}\;\frac{\rho_{*}+\rho_% {g}}{2}\bigg{)}+D_{KL}\bigg{(}\rho_{g}\;\bigg{\|}\;\frac{\rho_{*}+\rho_{g}}{2}% \bigg{)}= - roman_log ( 4 ) + italic_D start_POSTSUBSCRIPT italic_K italic_L end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ divide start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT + italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_ARG start_ARG 2 end_ARG ) + italic_D start_POSTSUBSCRIPT italic_K italic_L end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ∥ divide start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT + italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_ARG start_ARG 2 end_ARG ) (3.22)
=log(4)+2JSD(ρρg)absent42𝐽𝑆𝐷conditionalsubscript𝜌subscript𝜌𝑔\displaystyle=-\log(4)+2\cdot JSD(\rho_{*}\parallel\rho_{g})= - roman_log ( 4 ) + 2 ⋅ italic_J italic_S italic_D ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT )

where JSD𝐽𝑆𝐷JSDitalic_J italic_S italic_D is the Jensen-Shannon divergence[manning1999foundations]. Such quantity has the same non-negativity property of KL divergence, i.e. JSD(ρρg)0𝐽𝑆𝐷conditionalsubscript𝜌subscript𝜌𝑔0JSD(\rho_{*}\parallel\rho_{g})\geq 0italic_J italic_S italic_D ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) ≥ 0 and JSD(ρρg)=0𝐽𝑆𝐷conditionalsubscript𝜌subscript𝜌𝑔0JSD(\rho_{*}\parallel\rho_{g})=0italic_J italic_S italic_D ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT ) = 0 iff ρg=ρsubscript𝜌𝑔subscript𝜌\rho_{g}=\rho_{*}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. This proves that ρg=ρsubscript𝜌𝑔subscript𝜌\rho_{g}=\rho_{*}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, or more precisely the corresponding generator Gsuperscript𝐺G^{*}italic_G start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT, is the global minimum for C(G)𝐶𝐺C(G)italic_C ( italic_G ). ∎

To summarize, we have showed separate theoretical guarantees about convergence of gradient ascent and descent. However, we need to show that alternating those two steps would eventually converge to the global Nash equilibrium of the minimax game, i.e. ρ=ρgsubscript𝜌subscript𝜌𝑔\rho_{*}=\rho_{g}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT. The result is summarized in the following Theorem[gan_proo, goodfellow2014generative] of which omit the proof for the sake of brevity.

Theorem 3.3.

If G𝐺Gitalic_G and D𝐷Ditalic_D have enough capacity, and at each step of the alternating algorithm, the discriminator is allowed to reach its optimum given G𝐺Gitalic_G, and ρgsubscript𝜌𝑔\rho_{g}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT is updated so as to improve the criterion

𝔼[logDG(x)]+𝔼ρg[log(1DG(x)]\mathbb{E}_{*}[\log D^{*}_{G}(x)]+\mathbb{E}_{\rho_{g}}[\log(1-D_{G}^{*}(x)]blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_D start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT ( italic_x ) ] + blackboard_E start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT [ roman_log ( 1 - italic_D start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( italic_x ) ] (3.23)

then ρgsubscript𝜌𝑔\rho_{g}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT converges to ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT.

Ideally, the theoretical treatment of Generative Adversarial Networks (GANs) concludes with the proof that the proposed minimax game has a unique Nash equilibrium. This equilibrium corresponds to a generator capable of sampling from ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, making it indistinguishable from true samples by the discriminator, performing no better than a random classifier with a probability of 1/2121/21 / 2.
We now discuss the main drawbacks[gan_proo, radford2016unsupervised, salimans2016improved, arjovsky2016towards] of GANs. Firstly, practical application of Theorem 3.3 reveals immediate limitations. In practice, optimization involving gradients is executed in parameter space on θgsubscript𝜃𝑔\theta_{g}italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT rather than in functional space on ρgsubscript𝜌𝑔\rho_{g}italic_ρ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT. This deviation introduces challenges, as a convex problem in probability space may become non-convex, especially when using deep neural networks to model G𝐺Gitalic_G: in fact, the induced loss function becomes inherently non-convex. Additionally, a numerical issue arises when attempting to find the perfect discriminator DGsubscriptsuperscript𝐷𝐺D^{*}_{G}italic_D start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_G end_POSTSUBSCRIPT at a fixed G𝐺Gitalic_G; backpropagation to train the generator (specifically because the term D(Gθg(z))𝐷subscript𝐺subscript𝜃𝑔𝑧D(G_{\theta_{g}}(z))italic_D ( italic_G start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_g end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_z ) )) may yield gradients close to zero by definition at the beginning of training when the generator is very poor.
Regarding practical aspects, GAN training is notorious for its instability. Achieving the right balance between the generator and discriminator can be delicate, leading to oscillations during the training process and making it difficult to converge to a stable solution. This instability often requires careful tuning of hyperparameters, adding an extra layer of complexity to the training process. Additionally, GANs often require large and diverse datasets for training to generalize well.
Also generating samples from a trained GAN poses significant challenges. A critical one is mode collapse, where the generator tends to produce a limited set of outputs, neglecting the diversity present in the training data. This results in generated samples lacking variety and richness. Furthermore, GANs can be computationally intensive, especially when dealing with high-resolution images or complex datasets. This computational demand can be a hindrance for researchers and practitioners with limited resources, both in terms of time and hardware. Ultimately, evaluating the performance of a GAN can be problematic. Common metrics like Inception Score and Frechet Inception Distance have limitations, and there is no universally accepted metric for assessing the quality of generated samples. This lack of clear evaluation criteria makes it challenging to compare different GAN models effectively.
Despite the mentioned issues, the adversarial paradigm represents an important concept in unsupervised learning, in particular in relation with robustness of pre-trained generative models[madry2018towards], and generally machine learning models.

3.3 Diffusion Models

Diffusion generative models[sohl2015deep, yang2023diffusion, croitoru2023diffusion] typically refer to a class of generative models that leverage the concept of diffusion processes. In the context of generative models, diffusion processes involve the transformation of a simple distribution into a more complex one over time. This transformation occurs through a series of steps, each representing a diffusion process. The overarching idea is to initiate the process with a basic distribution, such as Gaussian noise, and iteratively transform it to approximate the target distribution, often representing real data like images. In recent years they have become state of the art in many domains of application, partially substituting GANs[dhariwal2021diffusion]. In this section we provide a summary of the main common features of diffusion models, without entering too much in details about every single specification currently available.
As for other generative models, the main ingredient is a dataset 𝒳={xi}i=1N𝒳subscriptsuperscriptsubscript𝑥𝑖𝑁𝑖1\mathcal{X}=\{x_{i}\}^{N}_{i=1}caligraphic_X = { italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT } start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT where xisubscript𝑥𝑖x_{i}italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT are sampled from an unknown target density ρ(x)subscript𝜌𝑥\rho_{*}(x)italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ). We will assume 𝒳d𝒳superscript𝑑\mathcal{X}\subset\mathbb{R}^{d}caligraphic_X ⊂ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT for simplicity. Both for VAEs and GANs, the idea is to generate new samples from noise, that is respectively decoding from a gaussian in latent space, or generate from noise via G𝐺Gitalic_G in GANs. In diffusion models, the objective is again to push samples extracted from a simple distribution, like a gaussian, towards the data distribution.
Since the main content of the following will be strictly related to stochastic calculus[rogers2000diffusions], let us fix the notation. We will refer to Xtdsubscript𝑋𝑡superscript𝑑X_{t}\in\mathbb{R}^{d}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT as a stochastic process, that is a sequence of random variables, where t𝑡t\in\mathbb{R}italic_t ∈ blackboard_R is the continuous time variable. Differently from deterministic processes, the focus is on the distribution in law of Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT, namely ρ(x,t)𝜌𝑥𝑡\rho(x,t)italic_ρ ( italic_x , italic_t ), and not on the single trajectory. As deterministic trajectories can be solutions of ordinary differential equations (ODEs), a stochastic process can be solution of a stochastic differential equation (SDE).

Proposition 3.2 (SDE and Fokker-Plank PDE).

Given the drift μ:d×d:𝜇superscript𝑑superscript𝑑\mu:\mathbb{R}^{d}\times\mathbb{R}\to\mathbb{R}^{d}italic_μ : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT × blackboard_R → blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT and the diffusion matrix σ:d×d,d:𝜎superscript𝑑superscript𝑑𝑑\sigma:\mathbb{R}^{d}\times\mathbb{R}\to\mathbb{R}^{d,d}italic_σ : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT × blackboard_R → blackboard_R start_POSTSUPERSCRIPT italic_d , italic_d end_POSTSUPERSCRIPT, let us consider the stochastic process Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT solution for t[0,T][0,+]𝑡0𝑇0t\in[0,T]\subset[0,+\infty]italic_t ∈ [ 0 , italic_T ] ⊂ [ 0 , + ∞ ] of the SDE

dXt=μ(Xt,t)dt+σ(Xt,t)dWt,X0ρ0formulae-sequence𝑑subscript𝑋𝑡𝜇subscript𝑋𝑡𝑡𝑑𝑡𝜎subscript𝑋𝑡𝑡𝑑subscript𝑊𝑡similar-tosubscript𝑋0subscript𝜌0dX_{t}=\mu(X_{t},t)dt+\sigma(X_{t},t)dW_{t},\quad\quad X_{0}\sim\rho_{0}italic_d italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_μ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) italic_d italic_t + italic_σ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT (3.24)

where Wtsubscript𝑊𝑡W_{t}italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT is a Wiener process. Using Ito convention, the law of Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT, namely ρ(x,t)𝜌𝑥𝑡\rho(x,t)italic_ρ ( italic_x , italic_t ), satisfies the Fokker-Planck partial differential equation (PDE)

tρ(x,t)=[μ(x,t)ρ(x,t)]+Δ[σ(x,t)22ρ(x,t)],ρ(x,0)=ρ0(x)formulae-sequence𝑡𝜌𝑥𝑡delimited-[]𝜇𝑥𝑡𝜌𝑥𝑡Δdelimited-[]𝜎superscript𝑥𝑡22𝜌𝑥𝑡𝜌𝑥0subscript𝜌0𝑥{\displaystyle{\frac{\partial}{\partial t}}\rho(x,t)=-\nabla\cdot\left[\mu(x,t% )\rho(x,t)\right]+\Delta\left[\frac{\sigma(x,t)^{2}}{2}\rho(x,t)\right],}\quad% \quad\rho(x,0)=\rho_{0}(x)divide start_ARG ∂ end_ARG start_ARG ∂ italic_t end_ARG italic_ρ ( italic_x , italic_t ) = - ∇ ⋅ [ italic_μ ( italic_x , italic_t ) italic_ρ ( italic_x , italic_t ) ] + roman_Δ [ divide start_ARG italic_σ ( italic_x , italic_t ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG start_ARG 2 end_ARG italic_ρ ( italic_x , italic_t ) ] , italic_ρ ( italic_x , 0 ) = italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( italic_x ) (3.25)

This proposition is important to understand the relation between the single random process Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT and its distribution in law. Let us present a simple example to clarify such connection.

Example 3.1 (Wiener process).

Let us consider the case μ(x,t)=0𝜇𝑥𝑡0\mu(x,t)=0italic_μ ( italic_x , italic_t ) = 0 and σ(x,t)=1𝜎𝑥𝑡1\sigma(x,t)=1italic_σ ( italic_x , italic_t ) = 1 in d=1𝑑1d=1italic_d = 1, that corresponds to the SDE

dXt=dWt𝑑subscript𝑋𝑡𝑑subscript𝑊𝑡dX_{t}=dW_{t}italic_d italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT (3.26)

The solution of the associated Fokker-Planck equation

ρ(x,t)t=122ρ(x,t)x2,𝜌𝑥𝑡𝑡12superscript2𝜌𝑥𝑡superscript𝑥2\displaystyle{\frac{\partial\rho(x,t)}{\partial t}}={\frac{1}{2}}{\frac{% \partial^{2}\rho(x,t)}{\partial x^{2}}},divide start_ARG ∂ italic_ρ ( italic_x , italic_t ) end_ARG start_ARG ∂ italic_t end_ARG = divide start_ARG 1 end_ARG start_ARG 2 end_ARG divide start_ARG ∂ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_ρ ( italic_x , italic_t ) end_ARG start_ARG ∂ italic_x start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG , (3.27)

for a delta initial datum ρ(x,0)=δ(x)𝜌𝑥0𝛿𝑥\rho(x,0)=\delta(x)italic_ρ ( italic_x , 0 ) = italic_δ ( italic_x ) is precisely

ρ(x,t)=12πtex2/2t𝜌𝑥𝑡12𝜋𝑡superscript𝑒superscript𝑥22𝑡\rho(x,t)=\frac{1}{\sqrt{2\pi t}}e^{-x^{2}/2t}italic_ρ ( italic_x , italic_t ) = divide start_ARG 1 end_ARG start_ARG square-root start_ARG 2 italic_π italic_t end_ARG end_ARG italic_e start_POSTSUPERSCRIPT - italic_x start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT / 2 italic_t end_POSTSUPERSCRIPT (3.28)

This is a gaussian density with variance proportional to t𝑡titalic_t. That is, the initial concentrated density spreads on the real line.

This brief summary about SDEs is sufficient to provide a consistent definition of generative diffusion model:

Definition 3.2 (Generative diffusion model).

Let us consider the data distribution ρ:d+:subscript𝜌superscript𝑑subscript\rho_{*}:\mathbb{R}^{d}\to\mathbb{R}_{+}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT → blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT and a base distribution ρ¯(x):d+:¯𝜌𝑥superscript𝑑subscript\bar{\rho}(x):\mathbb{R}^{d}\to\mathbb{R}_{+}over¯ start_ARG italic_ρ end_ARG ( italic_x ) : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT → blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT. Given a time interval [0,T][0,]0𝑇0[0,T]\in[0,\infty][ 0 , italic_T ] ∈ [ 0 , ∞ ], a generative diffusion model is an SDE with fixed terminal condition

dXt=μ(Xt,t)dt+σ(Xt,t)dWt,X0ρ¯,XTρformulae-sequence𝑑subscript𝑋𝑡𝜇subscript𝑋𝑡𝑡𝑑𝑡𝜎subscript𝑋𝑡𝑡𝑑subscript𝑊𝑡formulae-sequencesimilar-tosubscript𝑋0¯𝜌similar-tosubscript𝑋𝑇subscript𝜌dX_{t}=\mu(X_{t},t)dt+\sigma(X_{t},t)dW_{t},\quad\quad X_{0}\sim\bar{\rho},% \quad X_{T}\sim\rho_{*}italic_d italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_μ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) italic_d italic_t + italic_σ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ over¯ start_ARG italic_ρ end_ARG , italic_X start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT (3.29)

where Wtsubscript𝑊𝑡W_{t}italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT is a Wiener process.

This definition resembles concepts from stochastic optimal control[fleming2012deterministic]: in fact, the terminal condition is not sufficient to uniquely fix μ(Xt,t)𝜇subscript𝑋𝑡𝑡\mu(X_{t},t)italic_μ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) and σ(Xt,t)𝜎subscript𝑋𝑡𝑡\sigma(X_{t},t)italic_σ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ). Under this point of view, the specification of a particular class of diffusion models reduces to a prescription on how to determine the drift and the diffusion matrix. In the following we will summarize two highlighted methods present in literature.

Score-based diffusion[song2020score].

To explain what is score-based diffusion we need the following preliminaries:

Definition 3.3.

Given a PDF ρ(x)𝜌𝑥\rho(x)italic_ρ ( italic_x ), the score is the vector field

s(x)=logρ(x)𝑠𝑥𝜌𝑥s(x)=\nabla\log\rho(x)italic_s ( italic_x ) = ∇ roman_log italic_ρ ( italic_x ) (3.30)
Proposition 3.3 (Naive score-based diffusion).

For any ε>0𝜀0\varepsilon>0italic_ε > 0 and ρ0(x)subscript𝜌0𝑥\rho_{0}(x)italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( italic_x ), the choice μ(x,t)=εs(x)=εlogρ(x)𝜇𝑥𝑡𝜀subscript𝑠𝑥𝜀subscript𝜌𝑥\mu(x,t)=\varepsilon s_{*}(x)=\varepsilon\nabla\log\rho_{*}(x)italic_μ ( italic_x , italic_t ) = italic_ε italic_s start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) = italic_ε ∇ roman_log italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) and σ=2ε𝜎2𝜀\sigma=\sqrt{2\varepsilon}italic_σ = square-root start_ARG 2 italic_ε end_ARG in (3.29) satisfies the endpoint condition for T=𝑇T=\inftyitalic_T = ∞.

Proof.

If we consider the Fokker-Planck PDE associated to (3.29) with the selected drift and variance, we have

tρ(x,t)=[s(x)ρ(x,t)+ρ(x,t)]=[ρ(x,t)log(ρ(x,t)ρ(x))]subscript𝑡𝜌𝑥𝑡delimited-[]subscript𝑠𝑥𝜌𝑥𝑡𝜌𝑥𝑡delimited-[]𝜌𝑥𝑡𝜌𝑥𝑡subscript𝜌𝑥\partial_{t}\rho(x,t)=\nabla\cdot[-s_{*}(x)\rho(x,t)+\nabla\rho(x,t)]=\nabla% \cdot\left[\rho(x,t)\nabla\log\left(\frac{\rho(x,t)}{\rho_{*}(x)}\right)\right]∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ ( italic_x , italic_t ) = ∇ ⋅ [ - italic_s start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_ρ ( italic_x , italic_t ) + ∇ italic_ρ ( italic_x , italic_t ) ] = ∇ ⋅ [ italic_ρ ( italic_x , italic_t ) ∇ roman_log ( divide start_ARG italic_ρ ( italic_x , italic_t ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) end_ARG ) ] (3.31)

By direct substitution, the stationary probability density ρ(x)subscript𝜌𝑥\rho_{*}(x)italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) is a solution. For uniqueness, we need to prove that any solution of the PDE would converge to this solution. A formal argument is based on Jordan-Kinderlehrer-Otto (JKO) variational formulation of Fokker-Planck equation[jordan1998variational], interpreted as a gradient flow in probability space with respect to Wasserstein-2 distance. An alternative way is the following: for any solution ρ(x,t)𝜌𝑥𝑡\rho(x,t)italic_ρ ( italic_x , italic_t ), we can compute the time derivative of the KL divergence between such solution and ρ(x)subscript𝜌𝑥\rho_{*}(x)italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ). If we define R=ρ/ρ𝑅𝜌subscript𝜌R=\rho/\rho_{*}italic_R = italic_ρ / italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT:

ddtDKL(ρρ)=ddtdρlogRdx=dtρlogRdx+dρRtRdx𝑑𝑑𝑡subscript𝐷KLconditional𝜌subscript𝜌𝑑𝑑𝑡subscriptsuperscript𝑑𝜌𝑅𝑑𝑥subscriptsuperscript𝑑subscript𝑡𝜌𝑅𝑑𝑥subscriptsuperscript𝑑𝜌𝑅subscript𝑡𝑅𝑑𝑥\frac{d}{dt}D_{\text{KL}}(\rho\parallel\rho_{*})=\frac{d}{dt}\int_{\mathbb{R}^% {d}}\rho\log R\,dx=\int_{\mathbb{R}^{d}}\partial_{t}\rho\log R\,dx+\int_{% \mathbb{R}^{d}}\frac{\rho}{R}\partial_{t}R\,dxdivide start_ARG italic_d end_ARG start_ARG italic_d italic_t end_ARG italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ ∥ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) = divide start_ARG italic_d end_ARG start_ARG italic_d italic_t end_ARG ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ roman_log italic_R italic_d italic_x = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ roman_log italic_R italic_d italic_x + ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT divide start_ARG italic_ρ end_ARG start_ARG italic_R end_ARG ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_R italic_d italic_x (3.32)

We can use Fokker-Planck equation to substitute tρsubscript𝑡𝜌\partial_{t}\rho∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ and integrate by parts:

ddtDKL(ρρ)=ddtdρlogRdx=dρ|logR|2𝑑x+dρtRdx𝑑𝑑𝑡subscript𝐷KLconditional𝜌subscript𝜌𝑑𝑑𝑡subscriptsuperscript𝑑𝜌𝑅𝑑𝑥subscriptsuperscript𝑑𝜌superscript𝑅2differential-d𝑥subscriptsuperscript𝑑subscript𝜌subscript𝑡𝑅𝑑𝑥\frac{d}{dt}D_{\text{KL}}(\rho\parallel\rho_{*})=\frac{d}{dt}\int_{\mathbb{R}^% {d}}\rho\log R\,dx=-\int_{\mathbb{R}^{d}}\rho|\nabla\log R|^{2}\,dx+\int_{% \mathbb{R}^{d}}\rho_{*}\partial_{t}R\,dxdivide start_ARG italic_d end_ARG start_ARG italic_d italic_t end_ARG italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ ∥ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) = divide start_ARG italic_d end_ARG start_ARG italic_d italic_t end_ARG ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ roman_log italic_R italic_d italic_x = - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ | ∇ roman_log italic_R | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_d italic_x + ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_R italic_d italic_x (3.33)

We notice that ρtR=(ρlogR)subscript𝜌subscript𝑡𝑅𝜌𝑅\rho_{*}\partial_{t}R=\nabla\cdot(\rho\log R)italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_R = ∇ ⋅ ( italic_ρ roman_log italic_R ), hence that the second addend is zero by integration by parts. The conclusion is that

ddtDKL(ρρ)=dρ|logR|2𝑑x0,𝑑𝑑𝑡subscript𝐷KLconditional𝜌subscript𝜌subscriptsuperscript𝑑𝜌superscript𝑅2differential-d𝑥0\frac{d}{dt}D_{\text{KL}}(\rho\parallel\rho_{*})=-\int_{\mathbb{R}^{d}}\rho|% \nabla\log R|^{2}\,dx\leq 0,divide start_ARG italic_d end_ARG start_ARG italic_d italic_t end_ARG italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ ∥ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) = - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ | ∇ roman_log italic_R | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_d italic_x ≤ 0 , (3.34)

concluding the proof. ∎

The result seems to say that we are able to build a diffusion generative models estimating the score of the target. In a data driven context, ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT is known just through data points and one has to face the problem of estimating ssubscript𝑠s_{*}italic_s start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. A possible approach[hyvarinen2005estimation] is score matching.

Definition 3.4 (Fisher divergence).

Given two PDFs ρ(x)𝜌𝑥\rho(x)italic_ρ ( italic_x ) and π(x)𝜋𝑥\pi(x)italic_π ( italic_x ), the Fisher divergence is defined as

DF(ρπ)=dρ(x)logρ(x)logπ(x)2𝑑xsubscript𝐷𝐹conditional𝜌𝜋subscriptsuperscript𝑑𝜌𝑥superscriptdelimited-∥∥𝜌𝑥𝜋𝑥2differential-d𝑥D_{F}(\rho\parallel\pi)=\int_{\mathbb{R}^{d}}\rho(x)\lVert\nabla\log\rho(x)-% \nabla\log\pi(x)\rVert^{2}\,dxitalic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT ( italic_ρ ∥ italic_π ) = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ ( italic_x ) ∥ ∇ roman_log italic_ρ ( italic_x ) - ∇ roman_log italic_π ( italic_x ) ∥ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_d italic_x (3.35)

Even if in some sense DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT seems to measure some distance between two PDFs, it is very different from the KL divergence, see following Remark.

Remark 3.1.

By definition, both KL and Fisher divergence between two PDFs satisfy the non-negativity property, i.e. they are strictly positive, and zero only when the densities are the same. DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT does not depend on normalization constants of the PDFs because of the gradients. This is a double-edged weapon: it is apparently useful in high dimension, where the computation of normalization of a density is impractical (as for instance the partition function for EBMs). But if the distribution is multimodal, the local nature of DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT is very insensible to global characteristics of the densities, as for instance the relative mass in each mode. Let us consider a key example: the distributions we would like to compare are:

ρ1(x)=0.5𝒩(x,5,1)(x)+0.5𝒩(x,5,1),ρ2(x)=σ(z)𝒩(x,5,1)+(1σ(z))𝒩(x,5,1)formulae-sequencesubscript𝜌1𝑥0.5𝒩𝑥51𝑥0.5𝒩𝑥51subscript𝜌2𝑥𝜎𝑧𝒩𝑥511𝜎𝑧𝒩𝑥51\begin{split}\rho_{1}(x)&=0.5\mathcal{N}(x,-5,1)(x)+0.5\mathcal{N}(x,5,1),\\ \rho_{2}(x)&=\sigma(z)\mathcal{N}(x,-5,1)+(1-\sigma(z))\mathcal{N}(x,5,1)\end{split}start_ROW start_CELL italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ) end_CELL start_CELL = 0.5 caligraphic_N ( italic_x , - 5 , 1 ) ( italic_x ) + 0.5 caligraphic_N ( italic_x , 5 , 1 ) , end_CELL end_ROW start_ROW start_CELL italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ( italic_x ) end_CELL start_CELL = italic_σ ( italic_z ) caligraphic_N ( italic_x , - 5 , 1 ) + ( 1 - italic_σ ( italic_z ) ) caligraphic_N ( italic_x , 5 , 1 ) end_CELL end_ROW (3.36)

where σ(z)=1/(1+ez)𝜎𝑧11superscript𝑒𝑧\sigma(z)=1/(1+e^{-z})italic_σ ( italic_z ) = 1 / ( 1 + italic_e start_POSTSUPERSCRIPT - italic_z end_POSTSUPERSCRIPT ) is a sigmoid function. The two densities are bimodal gaussian mixture in 1D with same means and variances; the second mixture is balanced with relative mass equal to 1/2121/21 / 2. We would like to compare DF(ρ1ρ2)subscript𝐷𝐹conditionalsubscript𝜌1subscript𝜌2D_{F}(\rho_{1}\parallel\rho_{2})italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) and DKL(ρ1ρ2)subscript𝐷KLconditionalsubscript𝜌1subscript𝜌2D_{\text{KL}}(\rho_{1}\parallel\rho_{2})italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) as functions of z𝑧zitalic_z. In Figure 4 we plot the two divergences in function of z𝑧zitalic_z. We estimate the expectations that define the two divergences using a Monte Carlo estimate, namely

DF(ρ1ρ2)i=1Nlogρ1(xi)logρ2(xi)2DKL(ρ1ρ2)i=1Nlog[ρ1(xi)ρ2(xi)]subscript𝐷𝐹conditionalsubscript𝜌1subscript𝜌2superscriptsubscript𝑖1𝑁superscriptdelimited-∥∥subscript𝜌1subscript𝑥𝑖subscript𝜌2subscript𝑥𝑖2subscript𝐷KLconditionalsubscript𝜌1subscript𝜌2superscriptsubscript𝑖1𝑁subscript𝜌1subscript𝑥𝑖subscript𝜌2subscript𝑥𝑖\begin{split}D_{F}(\rho_{1}\parallel\rho_{2})&\approx\sum_{i=1}^{N}\lVert% \nabla\log\rho_{1}(x_{i})-\nabla\log\rho_{2}(x_{i})\rVert^{2}\\ D_{\text{KL}}(\rho_{1}\parallel\rho_{2})&\approx\sum_{i=1}^{N}\log\left[\frac{% \rho_{1}(x_{i})}{\rho_{2}(x_{i})}\right]\end{split}start_ROW start_CELL italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) end_CELL start_CELL ≈ ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT ∥ ∇ roman_log italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) - ∇ roman_log italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ∥ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_CELL end_ROW start_ROW start_CELL italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ) end_CELL start_CELL ≈ ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT roman_log [ divide start_ARG italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) end_ARG ] end_CELL end_ROW (3.37)

where xiρ1(x)similar-tosubscript𝑥𝑖subscript𝜌1𝑥x_{i}\sim\rho_{1}(x)italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_x ). The minimum value is 00 and corresponds to z=0𝑧0z=0italic_z = 0, that is ρ1=ρ2subscript𝜌1subscript𝜌2\rho_{1}=\rho_{2}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT. The first difference is that the values of DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT are smaller of several order of magnitude — in general, this could be a problem in practical implementations. Most importantly, the shape of the curve is very different. In this one dimensional example we need N=10000𝑁10000N=10000italic_N = 10000 to appreciate a similar growth, even if DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT curve is more steep. For smaller N𝑁Nitalic_N, DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT is basically flat for z0𝑧0z\neq 0italic_z ≠ 0. This is related to the absence of points in low density regions, that is where the integrand in DFsubscript𝐷𝐹D_{F}italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT gives a non-zero contribution.

Refer to caption
Figure 4: Comparison between KL divergence and Fisher divergence for the two bimodal gaussian mixtures in (3.36). The variable z(0,)𝑧0z\in(0,\infty)italic_z ∈ ( 0 , ∞ ) is related to the relative mass of the two modes via a sigmoid function σ(z)(0,1)𝜎𝑧01\sigma(z)\in(0,1)italic_σ ( italic_z ) ∈ ( 0 , 1 ); the plots for z<0𝑧0z<0italic_z < 0 are analogous by symmetry. Notice the different scales of the y𝑦yitalic_y axes. The Monte Carlo estimation is performed using N=100,1000,10000𝑁100100010000N=100,1000,10000italic_N = 100 , 1000 , 10000 samples.

In score matching, one propose a parametric score sθsubscript𝑠𝜃s_{\theta}italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT, for instance a neural network, and train such model to match the true score ssubscript𝑠s_{*}italic_s start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. The loss on which the model is trained, using for instance gradient routines, is

(sθ,ρ)=12dρsθlogρ2𝑑x=𝔼[sθ2+tr(Jxsθ)]+Cpsubscript𝑠𝜃subscript𝜌12subscriptsuperscript𝑑subscript𝜌superscriptdelimited-∥∥subscript𝑠𝜃subscript𝜌2differential-d𝑥subscript𝔼delimited-[]superscriptdelimited-∥∥subscript𝑠𝜃2trsubscript𝐽𝑥subscript𝑠𝜃subscript𝐶𝑝\mathcal{L}(s_{\theta},\rho_{*})=\frac{1}{2}\int_{\mathbb{R}^{d}}\rho_{*}% \lVert s_{\theta}-\nabla\log\rho_{*}\rVert^{2}\,dx=\mathbb{E}_{*}[\lVert s_{% \theta}\rVert^{2}+\operatorname{tr}(J_{x}s_{\theta})]+C_{p}caligraphic_L ( italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) = divide start_ARG 1 end_ARG start_ARG 2 end_ARG ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT - ∇ roman_log italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_d italic_x = blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ ∥ italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ∥ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + roman_tr ( italic_J start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) ] + italic_C start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT (3.38)

where we integrated by parts, Cp=constsubscript𝐶𝑝𝑐𝑜𝑛𝑠𝑡C_{p}=constitalic_C start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT = italic_c italic_o italic_n italic_s italic_t does not depend on θ𝜃\thetaitalic_θ and Jxsubscript𝐽𝑥J_{x}italic_J start_POSTSUBSCRIPT italic_x end_POSTSUBSCRIPT is the Jacobian with respect to x𝑥xitalic_x. Denoting with ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT one (n.b. not unique) PDF associated to sθsubscript𝑠𝜃s_{\theta}italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT, the loss is evidently DF(ρρθ)subscript𝐷𝐹conditionalsubscript𝜌subscript𝜌𝜃D_{F}(\rho_{*}\parallel\rho_{\theta})italic_D start_POSTSUBSCRIPT italic_F end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ). The right hand side reformulation in (3.38) is crucial: the expectation 𝔼subscript𝔼\mathbb{E}_{*}blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT can be estimated using data points at our disposal, bypassing the problematic term logρsubscript𝜌\nabla\log\rho_{*}∇ roman_log italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT.
Unfortunately, the naive score-based approach is plagued by two fundamental issues that make it impractical. The first regards the score estimation itself: usually, data at our disposal comes from high density region of ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, that is the estimation of 𝔼subscript𝔼\mathbb{E}_{*}blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, hence of the score, will be inaccurate outside such areas. The problem is that the initial condition (e.g. noise) of the SDE is usually located far from data. An imprecise drift will critically affect the generation process, leading to unpredictable outcomes. The second regards the difference between the PDE and the practical implementation through (3.29). The generation problem is convex in probability space, i.e. ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT is the unique asymptotic stationary solution, but the rate of convergence of the law of Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT is critically related to the particular ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT in study, in particular in relation with multimodality and slow mixing. We will discuss in details about this issue in Section 4.4.
The next step towards state-of-the-art score-based diffusion is the following lemma[anderson1982reverse]:

Lemma 3.2.

Any SDE in the form

dXt=f(Xt,t)dt+g(t)dWt,X0ρ1,XTρ2formulae-sequence𝑑subscript𝑋𝑡𝑓subscript𝑋𝑡𝑡𝑑𝑡𝑔𝑡𝑑subscript𝑊𝑡formulae-sequencesimilar-tosubscript𝑋0subscript𝜌1similar-tosubscript𝑋𝑇subscript𝜌2dX_{t}=f(X_{t},t)dt+g(t)dW_{t},\quad\quad X_{0}\sim\rho_{1},\quad X_{T}\sim% \rho_{2}italic_d italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_f ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) italic_d italic_t + italic_g ( italic_t ) italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT (3.39)

with solution Xtρ(x,t)similar-tosubscript𝑋𝑡𝜌𝑥𝑡X_{t}\sim\rho(x,t)italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ∼ italic_ρ ( italic_x , italic_t ) admits an associated reversed SDE

dXs=[f(Xs,s)g(s)2logρ(x,s)]ds+g(s)dWs,XTρ2,X0ρ1formulae-sequence𝑑subscript𝑋𝑠delimited-[]𝑓subscript𝑋𝑠𝑠𝑔superscript𝑠2𝜌𝑥𝑠𝑑𝑠𝑔𝑠𝑑subscript𝑊𝑠formulae-sequencesimilar-tosubscript𝑋𝑇subscript𝜌2similar-tosubscript𝑋0subscript𝜌1dX_{s}=[f(X_{s},s)-g(s)^{2}\nabla\log\rho(x,s)]ds+g(s)dW_{s},\quad\quad X_{T}% \sim\rho_{2},\quad X_{0}\sim\rho_{1}italic_d italic_X start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT = [ italic_f ( italic_X start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT , italic_s ) - italic_g ( italic_s ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ∇ roman_log italic_ρ ( italic_x , italic_s ) ] italic_d italic_s + italic_g ( italic_s ) italic_d italic_W start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT (3.40)

where ds𝑑𝑠dsitalic_d italic_s is a negative infinitesimal time step and s𝑠sitalic_s flows backward from T𝑇Titalic_T to 00. By convention, (3.39) is also called forward SDE and (3.40) backward one.

Exploiting this result, we can define a score-based diffusion model:

Definition 3.5.

A score-based generative model is the backward SDE (3.40), where ρ1=ρsubscript𝜌1subscript𝜌\rho_{1}=\rho_{*}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT and ρ2=ρ¯subscript𝜌2¯𝜌\rho_{2}=\bar{\rho}italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT = over¯ start_ARG italic_ρ end_ARG.

Apparently, the situation is even worse with respect to score matching: the score in (3.40) is related to the law of Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT, i.e. it is time dependent and generally not analytically known — score estimation was already an issue for s(x)subscript𝑠𝑥s_{*}(x)italic_s start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ). The core idea in score-based diffusion is to extract information about logρ(x,s)𝜌𝑥𝑠\nabla\log\rho(x,s)∇ roman_log italic_ρ ( italic_x , italic_s ) from the forward process since the solutions of (3.39) and (3.40) have the same law, see Figure 5.

Refer to caption
Figure 5: Schematic representation of forward and backward process in score-based diffusion. Image taken from [song2020score].

By Definition 3.5, the forward process brings data to noise and the model to be learned is a time dependent parametric vector field sθ(x,t)subscript𝑠𝜃𝑥𝑡s_{\theta}(x,t)italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_t ). The loss used during the forward process to learn the score is:

SM(sθ(x,t))=𝔼t𝒰(0,T)𝔼ρ(x,t)[λ(t)sθ(x,t)logρ(x,t)2]subscript𝑆𝑀subscript𝑠𝜃𝑥𝑡subscript𝔼similar-to𝑡𝒰0𝑇subscript𝔼𝜌𝑥𝑡delimited-[]𝜆𝑡superscriptdelimited-∥∥subscript𝑠𝜃𝑥𝑡𝜌𝑥𝑡2\mathcal{L}_{SM}(s_{\theta}(x,t))=\mathbb{E}_{t\sim\mathcal{U}(0,T)}\mathbb{E}% _{\rho(x,t)}[\lambda(t)\lVert s_{\theta}(x,t)-\nabla\log\rho(x,t)\rVert^{2}]caligraphic_L start_POSTSUBSCRIPT italic_S italic_M end_POSTSUBSCRIPT ( italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_t ) ) = blackboard_E start_POSTSUBSCRIPT italic_t ∼ caligraphic_U ( 0 , italic_T ) end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT italic_ρ ( italic_x , italic_t ) end_POSTSUBSCRIPT [ italic_λ ( italic_t ) ∥ italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_t ) - ∇ roman_log italic_ρ ( italic_x , italic_t ) ∥ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ] (3.41)

where λ:[0,T]+:𝜆0𝑇subscript\lambda:[0,T]\to\mathbb{R}_{+}italic_λ : [ 0 , italic_T ] → blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT is a positive scalar weight function and U(0,T)𝑈0𝑇{U}(0,T)italic_U ( 0 , italic_T ) is the uniform distribution in (0,T)0𝑇(0,T)( 0 , italic_T ). After the same integration by parts used in (3.41), there is still the problem that computing the hessian is expensive in high dimension, especially if sθsubscript𝑠𝜃s_{\theta}italic_s start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is a neural network. Several proposal to solve this issue have been proposed and successfully exploited, such as denoising score matching[vincent2011connection] or sliced score matching[song2020sliced]. Another subtle issue is that generally the forward process would generate pure noise for T=𝑇T=\inftyitalic_T = ∞ — one could be worried that the truncation at finite time would provide an imprecise estimate of the score at that time scale, that is close to noise, and induce errors during the generative phase. This problem is attacked by practitioners via several tricks but the theoretical results in this sense are not complete.
Let us provide a brief interpretation of why score-based diffusion works better than naive score matching (Proposition 3.3). Let us consider the simple case f(x,t)=0𝑓𝑥𝑡0f(x,t)=0italic_f ( italic_x , italic_t ) = 0 and g(t)=et𝑔𝑡superscript𝑒𝑡g(t)=e^{t}italic_g ( italic_t ) = italic_e start_POSTSUPERSCRIPT italic_t end_POSTSUPERSCRIPT; the resulting forward process is perturbing data with gaussian noise at increasing variance scale[song2021train]. That is, time scale corresponds to amount of noise in this setup. We recall that the problem of naive score matching was the lack of data in low density region for the target density. In score-based diffusion one use perturbed data to populate those region and compute the score at each time scale that serves as bridge from ρ¯¯𝜌\bar{\rho}over¯ start_ARG italic_ρ end_ARG and the target ρsuperscript𝜌\rho^{*}italic_ρ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT.

Stochastic Interpolants.

Another more recent class of diffusion-based generative models are the stochastic interpolants[albergo2022building]. Let us immediately provide a definition of such objects:

Definition 3.6.

Given two probability densities ρ1,ρ2:d+:subscript𝜌1subscript𝜌2superscript𝑑subscript\rho_{1},\rho_{2}:\mathbb{R}^{d}\to\mathbb{R}_{+}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT : blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT → blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT, a stochastic interpolant between them is a stochastic process Xtdsubscript𝑋𝑡superscript𝑑X_{t}\in\mathbb{R}^{d}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT such that

Xt=I(t,X0,X1)+γ(t)zt[0,1]formulae-sequencesubscript𝑋𝑡𝐼𝑡subscript𝑋0subscript𝑋1𝛾𝑡𝑧𝑡01X_{t}=I(t,X_{0},X_{1})+\gamma(t)z\quad\quad t\in[0,1]italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + italic_γ ( italic_t ) italic_z italic_t ∈ [ 0 , 1 ] (3.42)

where:

  • The function I𝐼Iitalic_I is of class C2superscript𝐶2C^{2}italic_C start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT on its domain and satisfy the following endpoint conditions

    I(i,X0,X1)=Xii=0,1formulae-sequence𝐼𝑖subscript𝑋0subscript𝑋1subscript𝑋𝑖𝑖01I(i,X_{0},X_{1})=X_{i}\quad\quad i=0,1italic_I ( italic_i , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) = italic_X start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT italic_i = 0 , 1 (3.43)

    as well as

    C1<:|tI(t,X0,X1)|C1|X0X1|(t,X0,X1)[0,1]×d×d:subscript𝐶1formulae-sequencesubscript𝑡𝐼𝑡subscript𝑋0subscript𝑋1subscript𝐶1subscript𝑋0subscript𝑋1for-all𝑡subscript𝑋0subscript𝑋101superscript𝑑superscript𝑑\exists C_{1}<\infty\,:\,\left|\partial_{t}I\left(t,X_{0},X_{1}\right)\right|% \leq C_{1}\left|X_{0}-X_{1}\right|\quad\forall\left(t,X_{0},X_{1}\right)\in[0,% 1]\times\mathbb{R}^{d}\times\mathbb{R}^{d}∃ italic_C start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT < ∞ : | ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) | ≤ italic_C start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT | italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT - italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT | ∀ ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) ∈ [ 0 , 1 ] × blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT × blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT (3.44)
  • γ:[0,1]:𝛾01\gamma:[0,1]\to\mathbb{R}italic_γ : [ 0 , 1 ] → blackboard_R is such that γ(0)=γ(1)=0𝛾0𝛾10\gamma(0)=\gamma(1)=0italic_γ ( 0 ) = italic_γ ( 1 ) = 0 and γ(t)>0𝛾𝑡0\gamma(t)>0italic_γ ( italic_t ) > 0 for t(0,1)𝑡01t\in(0,1)italic_t ∈ ( 0 , 1 ).

  • The pair (X0,X1)subscript𝑋0subscript𝑋1(X_{0},X_{1})( italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) is sampled from a measure ν𝜈\nuitalic_ν that marginalizes on ρ0subscript𝜌0\rho_{0}italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and ρ1subscript𝜌1\rho_{1}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, that is ν(dX0,d)=ρ0dX0𝜈𝑑subscript𝑋0superscript𝑑subscript𝜌0𝑑subscript𝑋0\nu(dX_{0},\mathbb{R}^{d})=\rho_{0}dX_{0}italic_ν ( italic_d italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ) = italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT italic_d italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and ν(d,dX1)=ρ1dX1𝜈superscript𝑑𝑑subscript𝑋1subscript𝜌1𝑑subscript𝑋1\nu(\mathbb{R}^{d},dX_{1})=\rho_{1}dX_{1}italic_ν ( blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT , italic_d italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) = italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT italic_d italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT.

  • The variable z𝑧zitalic_z is a Gaussian random variable independent from (X0,X1)subscript𝑋0subscript𝑋1(X_{0},X_{1})( italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ), i.e. z𝒩(𝟎d,𝑰d)similar-to𝑧𝒩subscript0𝑑subscript𝑰𝑑z\sim\mathcal{N}(\boldsymbol{0}_{d},\boldsymbol{I}_{d})italic_z ∼ caligraphic_N ( bold_0 start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT , bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT ) and z(X0,X1)perpendicular-to𝑧subscript𝑋0subscript𝑋1z\perp(X_{0},X_{1})italic_z ⟂ ( italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT )

Let us focus on the case in which ρ0=ρ¯subscript𝜌0¯𝜌\rho_{0}=\bar{\rho}italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = over¯ start_ARG italic_ρ end_ARG to be a simple base distribution (e.g. a Gaussian) and ρ1=ρsubscript𝜌1subscript𝜌\rho_{1}=\rho_{*}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, that is the data distribution. Equation (3.42) means that if we sample a couple X0ρ0similar-tosubscript𝑋0subscript𝜌0X_{0}\sim\rho_{0}italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and X1subscript𝑋1X_{1}italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT from the dataset, the interpolant is a stochastic process that connects the two points. The objective is to build a generative model that, in some sense, learns from the interpolants the way to map samples from ρ¯¯𝜌\bar{\rho}over¯ start_ARG italic_ρ end_ARG to ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. The first important result in this sense is the following[albergo2022building]:

Proposition 3.4.

The interpolant Xtsubscript𝑋𝑡X_{t}italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT is distributed at any time t[0,1]𝑡01t\in[0,1]italic_t ∈ [ 0 , 1 ] following a time dependent density ρ(x,t)𝜌𝑥𝑡\rho(x,t)italic_ρ ( italic_x , italic_t ) such that ρ(x,0)=ρ0𝜌𝑥0subscript𝜌0\rho(x,0)=\rho_{0}italic_ρ ( italic_x , 0 ) = italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and ρ(x,1)=ρ1𝜌𝑥1subscript𝜌1\rho(x,1)=\rho_{1}italic_ρ ( italic_x , 1 ) = italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, and also satisfies the following transport equation:

tρ+(bρ)=0subscript𝑡𝜌𝑏𝜌0\partial_{t}\rho+\nabla\cdot(b\rho)=0∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ + ∇ ⋅ ( italic_b italic_ρ ) = 0 (3.45)

where the vector field b(x,t)𝑏𝑥𝑡b(x,t)italic_b ( italic_x , italic_t ) is defined by a conditional expectation:

b(x,t)=𝔼[X˙tXt=x]=𝔼[tI(t,X0,X1)+γ˙(t)zXt=X]𝑏𝑥𝑡𝔼delimited-[]conditionalsubscript˙𝑋𝑡subscript𝑋𝑡𝑥𝔼delimited-[]subscript𝑡𝐼𝑡subscript𝑋0subscript𝑋1conditional˙𝛾𝑡𝑧subscript𝑋𝑡𝑋b(x,t)=\mathbb{E}\left[\dot{X}_{t}\mid X_{t}=x\right]=\mathbb{E}\left[\partial% _{t}I\left(t,X_{0},X_{1}\right)+\dot{\gamma}(t)z\mid X_{t}=X\right]italic_b ( italic_x , italic_t ) = blackboard_E [ over˙ start_ARG italic_X end_ARG start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ∣ italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_x ] = blackboard_E [ ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + over˙ start_ARG italic_γ end_ARG ( italic_t ) italic_z ∣ italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_X ] (3.46)
Proof.

Let g(k,t)=𝔼eikXt𝑔𝑘𝑡𝔼superscript𝑒𝑖𝑘subscript𝑋𝑡g(k,t)=\mathbb{E}e^{ik\cdot X_{t}}italic_g ( italic_k , italic_t ) = blackboard_E italic_e start_POSTSUPERSCRIPT italic_i italic_k ⋅ italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT end_POSTSUPERSCRIPT the characteristic function of ρ(x,t)𝜌𝑥𝑡\rho(x,t)italic_ρ ( italic_x , italic_t ), that is

g(k,t)=𝔼eik(I(t,X0,X1)+γ(t)z)𝑔𝑘𝑡𝔼superscript𝑒𝑖𝑘𝐼𝑡subscript𝑋0subscript𝑋1𝛾𝑡𝑧g(k,t)=\mathbb{E}e^{ik\cdot(I(t,X_{0},X_{1})+\gamma(t)z)}italic_g ( italic_k , italic_t ) = blackboard_E italic_e start_POSTSUPERSCRIPT italic_i italic_k ⋅ ( italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + italic_γ ( italic_t ) italic_z ) end_POSTSUPERSCRIPT (3.47)

If we compute the time derivative of g𝑔gitalic_g, we obtain

tg(k,t)=ikm(k,t)subscript𝑡𝑔𝑘𝑡𝑖𝑘𝑚𝑘𝑡\partial_{t}g(k,t)=ik\cdot m(k,t)∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_g ( italic_k , italic_t ) = italic_i italic_k ⋅ italic_m ( italic_k , italic_t ) (3.48)

where m(k,t)=𝔼[(tI(t,X0,X1)+γ˙(t)z)eikXt]𝑚𝑘𝑡𝔼delimited-[]subscript𝑡𝐼𝑡subscript𝑋0subscript𝑋1˙𝛾𝑡𝑧superscript𝑒𝑖𝑘subscript𝑋𝑡m(k,t)=\mathbb{E}[(\partial_{t}I\left(t,X_{0},X_{1}\right)+\dot{\gamma}(t)z)e^% {ik\cdot X_{t}}]italic_m ( italic_k , italic_t ) = blackboard_E [ ( ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + over˙ start_ARG italic_γ end_ARG ( italic_t ) italic_z ) italic_e start_POSTSUPERSCRIPT italic_i italic_k ⋅ italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT end_POSTSUPERSCRIPT ]. By definition of conditional expectation,

m(k,t)=d𝔼[(tI(t,X0,X1)+γ˙(t)z)eikXtXt=x]ρ(x,t)𝑑x=deikxb(x,t)ρ(x,t)𝑑x𝑚𝑘𝑡subscriptsuperscript𝑑𝔼delimited-[]conditionalsubscript𝑡𝐼𝑡subscript𝑋0subscript𝑋1˙𝛾𝑡𝑧superscript𝑒𝑖𝑘subscript𝑋𝑡subscript𝑋𝑡𝑥𝜌𝑥𝑡differential-d𝑥subscriptsuperscript𝑑superscript𝑒𝑖𝑘𝑥𝑏𝑥𝑡𝜌𝑥𝑡differential-d𝑥\begin{split}m(k,t)&=\int_{\mathbb{R}^{d}}\mathbb{E}[(\partial_{t}I\left(t,X_{% 0},X_{1}\right)+\dot{\gamma}(t)z)e^{ik\cdot X_{t}}\mid X_{t}=x]\rho(x,t)dx\\ &=\int_{\mathbb{R}^{d}}e^{ik\cdot x}b(x,t)\rho(x,t)dx\end{split}start_ROW start_CELL italic_m ( italic_k , italic_t ) end_CELL start_CELL = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT blackboard_E [ ( ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + over˙ start_ARG italic_γ end_ARG ( italic_t ) italic_z ) italic_e start_POSTSUPERSCRIPT italic_i italic_k ⋅ italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT end_POSTSUPERSCRIPT ∣ italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_x ] italic_ρ ( italic_x , italic_t ) italic_d italic_x end_CELL end_ROW start_ROW start_CELL end_CELL start_CELL = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_e start_POSTSUPERSCRIPT italic_i italic_k ⋅ italic_x end_POSTSUPERSCRIPT italic_b ( italic_x , italic_t ) italic_ρ ( italic_x , italic_t ) italic_d italic_x end_CELL end_ROW (3.49)

where we used the definition of b𝑏bitalic_b. If we insert m(k,t)𝑚𝑘𝑡m(k,t)italic_m ( italic_k , italic_t ) in (3.48) and we compute the Fourier anti-transform, we immediately obtain (3.45) in real space. ∎

Other properties of b𝑏bitalic_b can be proven, but for the sake of the present summary we will not delve into them. As usual we can identify ρ¯¯𝜌\bar{\rho}over¯ start_ARG italic_ρ end_ARG and ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT as base and data distributions. Thanks to the previous Proposition we can already define a diffusion-based generative model:

Lemma 3.3 (ODE Generative Model).

Given Proposition 3.4 and ρ(x,0)=ρ¯𝜌𝑥0¯𝜌\rho(x,0)=\bar{\rho}italic_ρ ( italic_x , 0 ) = over¯ start_ARG italic_ρ end_ARG, the choice μ(Xt,t)=b(Xt,t)𝜇subscript𝑋𝑡𝑡𝑏subscript𝑋𝑡𝑡\mu(X_{t},t)=b(X_{t},t)italic_μ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) = italic_b ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) and σ(Xt,t)=0𝜎subscript𝑋𝑡𝑡0\sigma(X_{t},t)=0italic_σ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) = 0 in (3.29) satisfies the endpoint condition for T=1𝑇1T=1italic_T = 1.

Differently from score-based diffusion models, such ODE-based formulation does not involve stochasticity during generation. In fact, the ODE X˙t=b(Xt,t)subscript˙𝑋𝑡𝑏subscript𝑋𝑡𝑡\dot{X}_{t}=b(X_{t},t)over˙ start_ARG italic_X end_ARG start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = italic_b ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) can be interpreted as a Normalizing Flow (see Section 6) where the pushforward is defined via a transport PDE. Interestingly, the ODE formulation is formally equivalent to an SDE formulation:

Lemma 3.4 (SDE Generative Model).

For ε>0𝜀0\varepsilon>0italic_ε > 0, given Proposition 3.4, ρ(x,0)=ρ¯𝜌𝑥0¯𝜌\rho(x,0)=\bar{\rho}italic_ρ ( italic_x , 0 ) = over¯ start_ARG italic_ρ end_ARG and the score s(x,t)=logρ(x,t)𝑠𝑥𝑡𝜌𝑥𝑡s(x,t)=\nabla\log\rho(x,t)italic_s ( italic_x , italic_t ) = ∇ roman_log italic_ρ ( italic_x , italic_t ), the choice μ(Xt,t)=b(Xt,t)+εs(Xt,t)𝜇subscript𝑋𝑡𝑡𝑏subscript𝑋𝑡𝑡𝜀𝑠subscript𝑋𝑡𝑡\mu(X_{t},t)=b(X_{t},t)+\varepsilon s(X_{t},t)italic_μ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) = italic_b ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) + italic_ε italic_s ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) and σ(Xt,t)=2ε𝜎subscript𝑋𝑡𝑡2𝜀\sigma(X_{t},t)=\sqrt{2\varepsilon}italic_σ ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT , italic_t ) = square-root start_ARG 2 italic_ε end_ARG in (3.29) satisfies the endpoint condition for T=1𝑇1T=1italic_T = 1.

Proof.

Adding and subtracting the score to (3.45), we obtain for any ε>0𝜀0\varepsilon>0italic_ε > 0

tρ+((b+εsεs)ρ)=0subscript𝑡𝜌𝑏𝜀𝑠𝜀𝑠𝜌0\partial_{t}\rho+\nabla\cdot((b+\varepsilon s-\varepsilon s)\rho)=0∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ + ∇ ⋅ ( ( italic_b + italic_ε italic_s - italic_ε italic_s ) italic_ρ ) = 0 (3.50)

But sρ=ρ𝑠𝜌𝜌s\rho=\nabla\rhoitalic_s italic_ρ = ∇ italic_ρ, that is

tρ+((b+εs)ρερ)=0subscript𝑡𝜌𝑏𝜀𝑠𝜌𝜀𝜌0\partial_{t}\rho+\nabla\cdot((b+\varepsilon s)\rho-\varepsilon\nabla\rho)=0∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ + ∇ ⋅ ( ( italic_b + italic_ε italic_s ) italic_ρ - italic_ε ∇ italic_ρ ) = 0 (3.51)

Trivially, the solution of the PDE (3.51) is the law of a stochastic process solution of an SDE as in (3.29). ∎

We presented the proof as an example of the standard trick used to convert the diffusion term into a transport term exploiting the score.
We defined the generative model, but similarly to score-based diffusion, we need to clarify how b𝑏bitalic_b and s𝑠sitalic_s are learned in practice from data. For such purpose, we present the following result:

Proposition 3.5.

The vector field b(x,t)𝑏𝑥𝑡b(x,t)italic_b ( italic_x , italic_t ) is the unique minimizer of the following objective loss

b[b^]=01𝔼(12|b^(t,Xt)|2(tI(t,X0,X1)+γ˙(t)z)b^(t,Xt))𝑑tsubscript𝑏delimited-[]^𝑏superscriptsubscript01𝔼12superscript^𝑏𝑡subscript𝑋𝑡2subscript𝑡𝐼𝑡subscript𝑋0subscript𝑋1˙𝛾𝑡𝑧^𝑏𝑡subscript𝑋𝑡differential-d𝑡\mathcal{L}_{b}[\hat{b}]=\int_{0}^{1}\mathbb{E}\left(\frac{1}{2}\left|\hat{b}% \left(t,X_{t}\right)\right|^{2}-\left(\partial_{t}I\left(t,X_{0},X_{1}\right)+% \dot{\gamma}(t)z\right)\cdot\hat{b}\left(t,X_{t}\right)\right)dtcaligraphic_L start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT [ over^ start_ARG italic_b end_ARG ] = ∫ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 1 end_POSTSUPERSCRIPT blackboard_E ( divide start_ARG 1 end_ARG start_ARG 2 end_ARG | over^ start_ARG italic_b end_ARG ( italic_t , italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ) | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT - ( ∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) + over˙ start_ARG italic_γ end_ARG ( italic_t ) italic_z ) ⋅ over^ start_ARG italic_b end_ARG ( italic_t , italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ) ) italic_d italic_t (3.52)

Similarly, the the score s(x,t)𝑠𝑥𝑡s(x,t)italic_s ( italic_x , italic_t ) the unique minimizer of the following objective loss

s[s^]=01𝔼(12|s^(t,Xt)|2+γ1(t)zs^(t,Xt))𝑑tsubscript𝑠delimited-[]^𝑠superscriptsubscript01𝔼12superscript^𝑠𝑡subscript𝑋𝑡2superscript𝛾1𝑡𝑧^𝑠𝑡subscript𝑋𝑡differential-d𝑡\mathcal{L}_{s}[\hat{s}]=\int_{0}^{1}\mathbb{E}\left(\frac{1}{2}\left|\hat{s}% \left(t,X_{t}\right)\right|^{2}+\gamma^{-1}(t)z\cdot\hat{s}\left(t,X_{t}\right% )\right)dtcaligraphic_L start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT [ over^ start_ARG italic_s end_ARG ] = ∫ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 1 end_POSTSUPERSCRIPT blackboard_E ( divide start_ARG 1 end_ARG start_ARG 2 end_ARG | over^ start_ARG italic_s end_ARG ( italic_t , italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ) | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + italic_γ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_t ) italic_z ⋅ over^ start_ARG italic_s end_ARG ( italic_t , italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT ) ) italic_d italic_t (3.53)

For the sake of the present summary, we will not present the proof[albergo2022building]. The take home message is that one can now propose two neural networks, namely bθ(x,t)subscript𝑏𝜃𝑥𝑡b_{\theta}(x,t)italic_b start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_t ) and sθ(x,t)subscript𝑠superscript𝜃𝑥𝑡s_{\theta^{\prime}}(x,t)italic_s start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x , italic_t ), and train them through backpropagation using (3.52) and (3.53). The integrals are estimated using random pairs (X0,X1)νsimilar-tosubscript𝑋0subscript𝑋1𝜈(X_{0},X_{1})\sim\nu( italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) ∼ italic_ν and times t𝒰[0,1]similar-to𝑡𝒰01t\sim\mathcal{U}[0,1]italic_t ∼ caligraphic_U [ 0 , 1 ]. As for score-based diffusion, we avoid delving into practical details regarding the implementation of the neural networks. We emphasize the main message: it is feasible to construct a diffusion model defined in a finite time interval that does not solely rely on the score function. In fact, score-based diffusion can be viewed as a specific instance of stochastic interpolation or similar methods (refer to Section 3.5 for more details).

Concerning practical aspects, the freedom in choosing the function I(t,X0,X1)𝐼𝑡subscript𝑋0subscript𝑋1I(t,X_{0},X_{1})italic_I ( italic_t , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) as well as γ(t)𝛾𝑡\gamma(t)italic_γ ( italic_t ) can be challenging due to the absence of a general guiding principle. Unfortunately, the structure of the interpolant and the implementation of bθsubscript𝑏𝜃b_{\theta}italic_b start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT and sθsubscript𝑠superscript𝜃s_{\theta^{\prime}}italic_s start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT can significantly impact the efficient training of the model. Regarding the generative phase, the SDE and ODE formulations are formally equivalent, but the practical choice is not straightforward. From a numerical perspective, the primary issue lies in the time discretization and integration of the differential equations. The ODE is preferred since integration methods are more stable and precise compared to those for SDEs; this allows for larger time steps and accelerated generation. This is also a significant advantage of stochastic interpolants over score-based diffusion, which is SDE-based. However, the presence of noise appears to be necessary as regularization: in layman’s terms, since b𝑏bitalic_b is learned and possibly imperfect, any mismatch is "smoothed" in the SDE setting by the presence of noise. The value of ε𝜀\varepsilonitalic_ε functions as a hyperparameter in this context.

In conclusion, stochastic interpolants provide a general framework closely related to other diffusion models, such as score-based diffusion, flow matching[liu2022flow, lipman2022flow], or Schrödinger bridge[de2021diffusion]. However, some common issues of diffusion-based generative models persist: slow generation, dependence on hyperparameters and neural architectures, and data dependence are the primary drawbacks.

3.4 Normalizing Flows

The fundamental idea underlying Normalizing Flows[tabak2010density, tabak2013family] (NF) is very close to the usual in generative modelling: to transform samples from a straightforward base distribution, often a Gaussian, to data distribution. The main feature of NF is that the transformation is performed through a series of invertible and differentiable transformations.

The core concept revolves around constructing a model capable of learning a sequence of invertible operations that can map samples from a simple distribution to the target distribution. In particular, we recall the well-known lemma:

Lemma 3.5.

Let us consider a random variable Zd𝑍superscript𝑑Z\in\mathbb{R}^{d}italic_Z ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT and its associated probability density function ρZ(z)subscript𝜌𝑍𝑧\rho_{Z}(z)italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_z ). Given an invertible function Y=ϕ(Z)𝑌italic-ϕ𝑍Y=\phi(Z)italic_Y = italic_ϕ ( italic_Z ) on dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, the probability density function in the variable Y𝑌Yitalic_Y is defined through

ρY(y)=ρZ(g1(y))|detJyφ1(y)|=ρZ(ϕ1(y))|detJyϕ(ϕ1(y))|1subscript𝜌𝑌𝑦subscript𝜌𝑍superscript𝑔1𝑦detsubscript𝐽𝑦superscript𝜑1𝑦subscript𝜌𝑍superscriptitalic-ϕ1𝑦superscriptdetsubscript𝐽𝑦italic-ϕsuperscriptitalic-ϕ1𝑦1\rho_{Y}(y)=\rho_{Z}(g^{-1}(y))|\operatorname{det}J_{y}\varphi^{-1}(y)|=\rho_{% Z}(\phi^{-1}(y))|\operatorname{det}J_{y}\phi(\phi^{-1}(y))|^{-1}italic_ρ start_POSTSUBSCRIPT italic_Y end_POSTSUBSCRIPT ( italic_y ) = italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_g start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) ) | roman_det italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT italic_φ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) | = italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_ϕ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) ) | roman_det italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT italic_ϕ ( italic_ϕ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) ) | start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT (3.54)

where ϕ1superscriptitalic-ϕ1\phi^{-1}italic_ϕ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT is the inverse of ϕitalic-ϕ\phiitalic_ϕ and Jysubscript𝐽𝑦J_{y}italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT is the Jacobian w.r.t. y𝑦yitalic_y. The density ρYsubscript𝜌𝑌\rho_{Y}italic_ρ start_POSTSUBSCRIPT italic_Y end_POSTSUBSCRIPT is also called pushforward of ρZsubscript𝜌𝑍\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT by the function ϕitalic-ϕ\phiitalic_ϕ and denoted by ϕ#ρZsubscriptitalic-ϕ#subscript𝜌𝑍\phi_{\#}\rho_{Z}italic_ϕ start_POSTSUBSCRIPT # end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT.

In generative modelling, ρZsubscript𝜌𝑍\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT is identified with the base distribution and its pushforward as the target, i.e. data, distribution. The direction from noise to data is called generative direction, while the other way is called normalizing direction — data are normalized, gaussianized, by the inverse of ϕitalic-ϕ\phiitalic_ϕ. The name Normalizing Flow originates from the latter. In fact, the mathematical foundation of NF is reduced to Lemma 3.5.
The whole problem reduces to design the pushforward in a data driven setup, that is where we just have a dataset 𝒳𝒳\mathcal{X}caligraphic_X of samples from the target and no access to the analytic form of ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. In order to link NF with other generative models, let us denote with ϕθsubscriptitalic-ϕ𝜃\phi_{\theta}italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT with θΘ𝜃Θ\theta\in\Thetaitalic_θ ∈ roman_Θ the parametric map that characterizes the pushforward ρθ=(ϕθ)#ρZsubscript𝜌𝜃subscriptsubscriptitalic-ϕ𝜃#subscript𝜌𝑍\rho_{\theta}=(\phi_{\theta})_{\#}\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = ( italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) start_POSTSUBSCRIPT # end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT. In practice, this map is usually a neural network and ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT will implicitly depend on it. The optimal parameters θsuperscript𝜃\theta^{*}italic_θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT are chosen to be solution of the following optimization problem:

θ=argminθΘDKL(ρ(x)ρθ(x))=argmaxθΘ𝔼[logρθ(x)]superscript𝜃subscriptargmin𝜃Θsubscript𝐷KLconditionalsubscript𝜌𝑥subscript𝜌𝜃𝑥subscriptargmax𝜃Θsubscript𝔼delimited-[]subscript𝜌𝜃𝑥\theta^{*}=\operatorname*{arg\,min}_{\theta\in\Theta}D_{\text{KL}}(\rho_{*}(x)% \parallel\rho_{\theta}(x))=\operatorname*{arg\,max}_{\theta\in\Theta}\mathbb{E% }_{*}[\log\rho_{\theta}(x)]italic_θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT = start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) ∥ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ) = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ] (3.55)

As already stressed, this formulation in term of maximum log-likelihood is equivalent to cross-entropy minimization for EBMs. As for VAEs, the analytical form of ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is not known: in NF it is implicitly defined through the pushforward. This issue is attacked using Lemma 3.5 to rewrite the right hand side in (3.55) as

argmaxθΘ𝔼[logρθ(x)]=argmaxθΘ𝔼[logρZ(ϕθ1(y))+log|detJyϕ1(y)|]subscriptargmax𝜃Θsubscript𝔼delimited-[]subscript𝜌𝜃𝑥subscriptargmax𝜃Θsubscript𝔼delimited-[]subscript𝜌𝑍superscriptsubscriptitalic-ϕ𝜃1𝑦detsubscript𝐽𝑦superscriptitalic-ϕ1𝑦\operatorname*{arg\,max}_{\theta\in\Theta}\mathbb{E}_{*}[\log\rho_{\theta}(x)]% =\operatorname*{arg\,max}_{\theta\in\Theta}\mathbb{E}_{*}[\log\rho_{Z}(\phi_{% \theta}^{-1}(y))+\log|\operatorname{det}J_{y}\phi^{-1}(y)|]start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ] = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) ) + roman_log | roman_det italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT italic_ϕ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) | ] (3.56)

The likelihood of a sample under the base measure is represented as the first term, and the second term, often referred to as the log-determinant or volume correction, accommodates the alteration in volume resulting from the transformation introduced by the normalizing flows. After this manipulation every addend inside the expectation is calculable — the map ϕitalic-ϕ\phiitalic_ϕ and the noise distribution ρZsubscript𝜌𝑍\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT are given (e.g. a gaussian). As usual, the expectation can estimated via Monte Carlo using the finite dataset 𝒳𝒳\mathcal{X}caligraphic_X at our disposal. Any gradient based optimization routine can be then exploited to optimize θ𝜃\thetaitalic_θ. During training, the model adjusts the parameters θ𝜃\thetaitalic_θ to bring the transformed distribution in close alignment with the true data distribution.

Refer to caption
Figure 6: Schematic representation of Normalizing Flows, image taken from [NFima].

The main limitation in NF is that the pushforward map must be bijective for any θ𝜃\thetaitalic_θ. Not only that: both forward and inverse operations are required to be computationally feasible to perform generation and normalization. Furthermore, the Jacobian determinant must be tractable to facilitate efficient computation. These requests constrain the possible neural architectures that one can use to model ϕθsubscriptitalic-ϕ𝜃\phi_{\theta}italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT. The following lemma provides a decisive tool in this sense.

Lemma 3.6.

Let us consider a set of M𝑀Mitalic_M bijective functions {fi}i=1Msuperscriptsubscriptsubscript𝑓𝑖𝑖1𝑀\{f_{i}\}_{i=1}^{M}{ italic_f start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_M end_POSTSUPERSCRIPT. If we denote with f=fMfM1f1𝑓subscript𝑓𝑀subscript𝑓𝑀1subscript𝑓1f=f_{M}\circ f_{M-1}\circ\dots\circ f_{1}italic_f = italic_f start_POSTSUBSCRIPT italic_M end_POSTSUBSCRIPT ∘ italic_f start_POSTSUBSCRIPT italic_M - 1 end_POSTSUBSCRIPT ∘ ⋯ ∘ italic_f start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT their composition, one can prove that f𝑓fitalic_f is bijective and its inverse is

f1=f11fM11fM1superscript𝑓1subscriptsuperscript𝑓11subscriptsuperscript𝑓1𝑀1subscriptsuperscript𝑓1𝑀f^{-1}=f^{-1}_{1}\circ\dots\circ f^{-1}_{M-1}\circ f^{-1}_{M}italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT = italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∘ ⋯ ∘ italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_M - 1 end_POSTSUBSCRIPT ∘ italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_M end_POSTSUBSCRIPT (3.57)

Moreover, if we denote with xi=fif1(z)=fi+11fM1subscript𝑥𝑖subscript𝑓𝑖subscript𝑓1𝑧subscriptsuperscript𝑓1𝑖1subscriptsuperscript𝑓1𝑀x_{i}=f_{i}\circ\dots\circ f_{1}(z)=f^{-1}_{i+1}\circ\dots\circ f^{-1}_{M}italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_f start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∘ ⋯ ∘ italic_f start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( italic_z ) = italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ∘ ⋯ ∘ italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_M end_POSTSUBSCRIPT and y=xM𝑦subscript𝑥𝑀y=x_{M}italic_y = italic_x start_POSTSUBSCRIPT italic_M end_POSTSUBSCRIPT, we have

detJyf1(y)=i=1MdetJyfi1(xi)detsubscript𝐽𝑦superscript𝑓1𝑦superscriptsubscriptproduct𝑖1𝑀detsubscript𝐽𝑦superscriptsubscript𝑓𝑖1subscript𝑥𝑖\operatorname{det}J_{y}f^{-1}(y)=\prod_{i=1}^{M}\operatorname{det}J_{y}f_{i}^{% -1}(x_{i})roman_det italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT italic_f start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) = ∏ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_M end_POSTSUPERSCRIPT roman_det italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT italic_f start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) (3.58)

Exploiting this factorization result, the strategy is to compose invertible building blocks (ϕθ)isubscriptsubscriptitalic-ϕ𝜃𝑖(\phi_{\theta})_{i}( italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT to construct a function ϕθsubscriptitalic-ϕ𝜃\phi_{\theta}italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT that is sufficiently expressive. In general, the architecture of Normalizing Flows encompasses various transformations (see Figure 6), including simple operations like affine transformations and permutations, as well as more complex functions such as coupling layers. Common flow architectures include RealNVP, Glow, and Planar Flows, each introducing unique ways to parameterize and structure transformations[kobyzev2020normalizing].
Regarding drawbacks of NF, one significant limitation lies in the computational cost associated with training NF, particularly as model complexity increases. The requirement for invertibility and the computation of determinants of Jacobian matrices contributes to the time-consuming nature of training, especially in deep architectures.

The architectural complexity of NF poses another challenge. Designing an optimal structure and tuning parameters may prove challenging, necessitating experimentation and careful consideration. Moreover, they may face challenges in scaling to extremely high-dimensional spaces, limiting their applicability in certain scenarios. Despite their expressiveness, NF may struggle to capture extremely complex distributions, requiring an impractical number of transformations to model certain intricate data distributions effectively.
Another degree of freedom is the choice of the base distribution ρZsubscript𝜌𝑍\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT, which can impact NF performance. Using a base distribution that does not align well with the true data distribution may hinder the model’s ability to accurately capture underlying patterns. Training NF is observed to be less stable compared to other generative models, requiring careful tuning of hyperparameters and training strategies to achieve convergence and avoid issues like mode collapse. Lastly, interpreting the learned representations and transformations within NF can be challenging, which is an obstacle for a straightforward comprehension of how the model captures and represents information.

3.5 Comparison and EBMs

In this section, we present a summarized comparison of EBMs and the other generative models. First of all, the main similarity is the objective: maximize the log-likelihood is the general aim. In Table 1 we present how this task is instantiated case by case.

Implementation of Maximum Log-Likelihood
EBM
Cross-Entropy Minimization
argminθΘ𝔼[Uθ]+logZθsubscriptargmin𝜃Θsubscript𝔼delimited-[]subscript𝑈𝜃subscript𝑍𝜃\operatorname*{arg\,min}_{\theta\in\Theta}\mathbb{E}_{*}[U_{\theta}]+\log Z_{\theta}start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] + roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT
VAE
Latent Space
argmaxθ,θi=1N1Ri=rRlogρθ(xi|zi(r))i=1NDKL[logqθ(zi|xi)ρ(zi)]subscriptargmax𝜃superscript𝜃superscriptsubscript𝑖1𝑁1𝑅superscriptsubscript𝑖𝑟𝑅subscript𝜌𝜃conditionalsubscript𝑥𝑖superscriptsubscript𝑧𝑖𝑟superscriptsubscript𝑖1𝑁subscript𝐷KLdelimited-[]conditionalsubscript𝑞superscript𝜃conditionalsubscript𝑧𝑖subscript𝑥𝑖𝜌subscript𝑧𝑖\operatorname*{arg\,max}_{\theta,\theta^{\prime}}\sum_{i=1}^{N}\frac{1}{R}\sum% _{i=r}^{R}\log\rho_{\theta}(x_{i}|z_{i}^{(r)})-\sum_{i=1}^{N}D_{\text{KL}}[% \log q_{\theta^{\prime}}(z_{i}|x_{i})\parallel\rho(z_{i})]start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ , italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG italic_R end_ARG ∑ start_POSTSUBSCRIPT italic_i = italic_r end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_R end_POSTSUPERSCRIPT roman_log italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( italic_r ) end_POSTSUPERSCRIPT ) - ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT [ roman_log italic_q start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ∥ italic_ρ ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ]
GAN
Minimax Game
argminθargmaxθ𝔼[logDθ(x)]+𝔼ρz[log(1Dθ(Gθ(z)))]subscriptargmin𝜃subscriptargmaxsuperscript𝜃subscript𝔼delimited-[]subscript𝐷superscript𝜃𝑥subscript𝔼subscript𝜌𝑧delimited-[]1subscript𝐷superscript𝜃subscript𝐺𝜃𝑧\operatorname*{arg\,min}_{\theta}\operatorname*{arg\,max}_{\theta^{\prime}}% \mathbb{E}_{*}[\log D_{\theta^{\prime}}(x)]+\mathbb{E}_{\rho_{z}}[\log(1-D_{% \theta^{\prime}}(G_{\theta}(z)))]start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x ) ] + blackboard_E start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_z end_POSTSUBSCRIPT end_POSTSUBSCRIPT [ roman_log ( 1 - italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_G start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_z ) ) ) ]
SBD or SI
Implicit via Transport-Diffusion Equation
tρ(x,t)+((bθ(x,t)+εsθ(x,t))ρ(x,t)ερ(x,t))=0subscript𝑡𝜌𝑥𝑡subscript𝑏𝜃𝑥𝑡𝜀subscript𝑠superscript𝜃𝑥𝑡𝜌𝑥𝑡𝜀𝜌𝑥𝑡0\partial_{t}\rho(x,t)+\nabla\cdot((b_{\theta}(x,t)+\varepsilon s_{\theta^{% \prime}}(x,t))\rho(x,t)-\varepsilon\nabla\rho(x,t))=0∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_ρ ( italic_x , italic_t ) + ∇ ⋅ ( ( italic_b start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x , italic_t ) + italic_ε italic_s start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x , italic_t ) ) italic_ρ ( italic_x , italic_t ) - italic_ε ∇ italic_ρ ( italic_x , italic_t ) ) = 0
NF
Volume Correction Factor
argmaxθΘ𝔼[logρZ(ϕθ1(y))+log|detJyϕθ1(y)|]subscriptargmax𝜃Θsubscript𝔼delimited-[]subscript𝜌𝑍superscriptsubscriptitalic-ϕ𝜃1𝑦detsubscript𝐽𝑦superscriptsubscriptitalic-ϕ𝜃1𝑦\operatorname*{arg\,max}_{\theta\in\Theta}\mathbb{E}_{*}[\log\rho_{Z}(\phi_{% \theta}^{-1}(y))+\log|\operatorname{det}J_{y}\phi_{\theta}^{-1}(y)|]start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_θ ∈ roman_Θ end_POSTSUBSCRIPT blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) ) + roman_log | roman_det italic_J start_POSTSUBSCRIPT italic_y end_POSTSUBSCRIPT italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) | ]
Table 1: Comparison of implementation of maximum log-likelihood for different generative models.

In generative models, there exists an inherent trade-off between the model’s ability to generate data and its alignment with real-world data. Essentially, the paradigm followed in each optimization step involves two key stages: (1) the generation of data using a fixed model, and (2) the evaluation of the model’s performance by comparing the generated ("fake") data with the actual dataset. This dual-step process is universally applicable, albeit with variations in implementation. It represents an interpretation of generative models as a balance between their discriminative and sampling capabilities. For conciseness, Table 2 provides a summary of specific details for each generative model.

Generation Evaluation
EBM MCMC Energy function
VAE Sampling from gaussian Fidelity of encoding-decoding
GAN Generator Discriminator
SBD (or SI) SDE (or ODE) Score (or vector field)
NF pushforward map Fidelity of Normalizing Flow
Table 2: Generation and evaluation for Generative Models.

The primary distinction among the Generative Models under examination lies in the manner in which they learn. In Normalizing Flows (NFs) and Generative Adversarial Networks (GANs), the focus is on directly learning a deterministic mapping from data to noise. Stochasticity enters the picture primarily through the selection of an initial datum for generation. Conversely, in Variational Autoencoders (VAEs), diffusion models, and Energy-Based Models (EBMs), generation is intrinsically linked to a sampling routine (such as Stochastic Differential Equations for Score-Based Diffusion). This disparity has its advantages and disadvantages: while deterministic generation can be more efficient, any inaccuracies in the learned generator, stemming from finite dataset sizes, tend to be amplified. Empirically, this mirrors the rationale behind employing SDEs rather than ODEs in stochastic interpolants: a noisy evolution serves as a regularizer. However, the magnitude of noise becomes a critical hyperparameter in diffusion models, as does the structure within latent space for VAEs. Currently, there is no universally applicable recipe for determining the best generative model for a specific problem.

The bidirectional nature of generative models (from noise or latent space to data, and vice versa) is a noteworthy common characteristic, except in the case of GANs, where the generation model lacks invertibility. Interestingly, it appears that more recent generative models, such as Score-Based Diffusion, enhance fidelity by leveraging information acquired during the "noising" process—transforming data into noise. To explore this perspective, the utilization of tools native to Mathematical Physics, particularly those related to stochastic processes, has proven necessary, suggesting that a meticulous examination of Generative Models through the lens of physical processes could be crucial for future advancements.

Now, let’s delve into a more detailed mathematical comparison, with a focus on Energy-Based Models (EBMs). Specifically, we demonstrate how, in certain cases, other generative models can be interpreted as EBMs:

  • For GANs, if the discriminator is Dθ(x)eUθ(x)proportional-tosubscript𝐷superscript𝜃𝑥superscript𝑒subscript𝑈superscript𝜃𝑥D_{\theta^{\prime}}(x)\propto e^{-U_{\theta^{\prime}}(x)}italic_D start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x ) ∝ italic_e start_POSTSUPERSCRIPT - italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x ) end_POSTSUPERSCRIPT, we immediately recover the term 𝔼[Uθ]subscript𝔼delimited-[]subscript𝑈𝜃\mathbb{E}_{*}[U_{\theta}]blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ]. The training of the generator correspond to learn a perfect sampler, and resemble the use of machine learning to improve MCMC in computational science[song2017nice].

  • For SBD and SI, if the score is modelled by sθ(x,t)Uθ(x)proportional-tosubscript𝑠superscript𝜃𝑥𝑡subscript𝑈superscript𝜃𝑥s_{\theta^{\prime}}(x,t)\propto-\nabla U_{\theta^{\prime}}(x)italic_s start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x , italic_t ) ∝ - ∇ italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_x ) the law of the process solution of the SDE is a Boltzmann-Gibbs ensemble by construction. Thus, the strong analogy is related to the constrained structure imposed to the law of the bridging process between the noise and the data, forced to be a BG ensemble. Regarding the loss, since the model is trained on Fisher divergence or on the interpolants, there is no direct analogy between the losses.

  • For NFs, if ϕθsubscriptitalic-ϕ𝜃\phi_{\theta}italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is the map associated to a flow that brings X0ρZ(ϕθ1(x))eUθ(x)similar-tosubscript𝑋0subscript𝜌𝑍superscriptsubscriptitalic-ϕ𝜃1𝑥proportional-tosuperscript𝑒subscript𝑈𝜃𝑥X_{0}\sim\rho_{Z}(\phi_{\theta}^{-1}(x))\propto e^{-U_{\theta}(x)}italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_x ) ) ∝ italic_e start_POSTSUPERSCRIPT - italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) end_POSTSUPERSCRIPT to X1ρsimilar-tosubscript𝑋1subscript𝜌X_{1}\sim\rho_{*}italic_X start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, then the term 𝔼[Uθ]subscript𝔼delimited-[]subscript𝑈𝜃\mathbb{E}_{*}[U_{\theta}]blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] present in EBMs is analogous to 𝔼[logρZ(ϕθ1(y))\mathbb{E}_{*}[\log\rho_{Z}(\phi_{\theta}^{-1}(y))blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ roman_log italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT ( italic_ϕ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_y ) ) for NFs. In practice, if the composition of ρZsubscript𝜌𝑍\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT with the normalizing flow can be written as an EBM, there is no difference between the models. This is of course not true in general — it is not given that for any θ𝜃\thetaitalic_θ, a composition of the inverse map ϕθ1subscriptsuperscriptitalic-ϕ1𝜃\phi^{-1}_{\theta}italic_ϕ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT and ρZsubscript𝜌𝑍\rho_{Z}italic_ρ start_POSTSUBSCRIPT italic_Z end_POSTSUBSCRIPT can be always associated to an EBM parameterized via Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT.

  • For VAEs the situation is a bit more intricate because of the ELBO reformulation. A possible interpretation towards EBMs is to think about encoder and decoder as a forward and backward processes from data to a latent space (possibly independent features, similarly to gaussian noise). One could imagine ρθ(xi|zi(r))subscript𝜌𝜃conditionalsubscript𝑥𝑖superscriptsubscript𝑧𝑖𝑟\rho_{\theta}(x_{i}|z_{i}^{(r)})italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( italic_r ) end_POSTSUPERSCRIPT ) and qθ(zi|xi)subscript𝑞superscript𝜃conditionalsubscript𝑧𝑖subscript𝑥𝑖q_{\theta^{\prime}}(z_{i}|x_{i})italic_q start_POSTSUBSCRIPT italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( italic_z start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT | italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) as EBMs that have to match with some constraint on the z𝑧zitalic_z space. In fact, the original EM steps represent an alternating optimization, where θ𝜃\thetaitalic_θ is not related to θsuperscript𝜃\theta^{\prime}italic_θ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. In this sense, VAEs tries to match the forward and backward processes, similarly to SBD where they are the same by construction of the score.

A fitting metaphor for generative models is to liken them to bridges connecting a "simple" source, such as noise, to real data. Just like constructing a physical bridge, building a generative model requires understanding the abutments. In the realm of data science, this translates to conducting statistical analysis of the dataset on one side, and selecting the appropriate noise source on the other. Additionally, modifying the docking configuration where the bridge is anchored—equivalent to data preprocessing—is often necessary. This step is crucial, akin to using the correct coordinates to describe a physical system. For instance, molecular configurations may not be easily trainable in standard three-dimensional space due to numerous implicit structural constraints.

Once the groundwork is laid, constructing the bridge begins. Just like real roads, different paths are tailored for different canyons, and similarly, for different data structures. Whether the bridge is bidirectional or not depends on the specific requirements. The key takeaway is always to maximize the log-likelihood between the model and the data distribution, ensuring that the bridge effectively connects the source to the desired destination.

4 EBMs and sampling

The challenge of sampling from the Boltzmann-Gibbs (BG) ensemble arises in statistical mechanics, particularly when dealing with complex systems at equilibrium. This ensemble encapsulates the probability distribution of states for a system with numerous interacting particles at a given temperature. The primary obstacle in that context lies in the exponential number of possible states and intricate dependencies among particles, rendering brute-force methods impractical for large systems. A similar difficulty is encountered during EBM training, since the computation of the expectation 𝔼θsubscript𝔼𝜃\mathbb{E}_{\theta}blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT requires the ability to sample from a Boltzmann-Gibbs density.

Let us restrict to the case in which the energy U(x)𝑈𝑥U(x)italic_U ( italic_x ) is defined on dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, that corresponds to continuous states in Statistical Physics. Any proposed techniques to efficiently sample from ρBG(x)=exp(U(x))/Zsubscript𝜌𝐵𝐺𝑥𝑈𝑥𝑍\rho_{BG}(x)=\exp(-U(x))/Zitalic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) = roman_exp ( - italic_U ( italic_x ) ) / italic_Z can rely just on U(x)𝑈𝑥U(x)italic_U ( italic_x ) or on its derivatives, even if the computation of many iterated derivatives can be expensive in high dimension. The estimation of the partition function or the shape of the energy landscape are in general unknown — on the contrary, they are the unknowns. Methods as rejecting sampling[casella2004generalized] cannot be used since one has usually access to U(x)𝑈𝑥U(x)italic_U ( italic_x ) and not to the normalized density ρBG(x)subscript𝜌𝐵𝐺𝑥\rho_{BG}(x)italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ). Since the advent of computational science, sampling has been attacked with many methods — a complete and exhaustive review of the existent methods would lead us off-topic. In this Section, we will highlight three common routines for sampling from a BG enseble: Metropolis-Hastings and Unadjusted Langevin Algorithm, and lastly Metropolis Adjusted Langevin Algorithm, a sort of fusion of the first two.
Let us better define the mathematical setting. We consider a space ΩdΩsuperscript𝑑\Omega\subseteq\mathbb{R}^{d}roman_Ω ⊆ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT and a discrete sequence (tk)k0subscriptsubscript𝑡𝑘𝑘0(t_{k})_{k\geq 0}\subset\mathbb{N}( italic_t start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) start_POSTSUBSCRIPT italic_k ≥ 0 end_POSTSUBSCRIPT ⊂ blackboard_N. Then, we consider XtkXksubscript𝑋subscript𝑡𝑘subscript𝑋𝑘X_{t_{k}}\coloneqq X_{k}italic_X start_POSTSUBSCRIPT italic_t start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ≔ italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT to be a stochastic process in ΩΩ\Omegaroman_Ω and discrete time. For the sake of simplicity we will always consider absolutely continuous densities with respect to Lebesgue measure.

Definition 4.1 (Informal).

Sampling from a BG ensemble consists in defining the process Xksubscript𝑋𝑘X_{k}italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT such that T>0𝑇0\exists T>0∃ italic_T > 0, not necessarily unique, for which XTexp(U(x))/Zsimilar-tosubscript𝑋𝑇𝑈𝑥𝑍X_{T}\sim\exp(-U(x))/Zitalic_X start_POSTSUBSCRIPT italic_T end_POSTSUBSCRIPT ∼ roman_exp ( - italic_U ( italic_x ) ) / italic_Z.

Once we manage to define such a process, and implement it in practice, we have solved the problem of sampling from a BG ensemble. A possible implicit way to define such stochastic process is via a transition kernel. Suppose we are interested in the law of the process X𝑋Xitalic_X at time k+1𝑘1k+1italic_k + 1, that we denote ρ(Xk+1)𝜌subscript𝑋𝑘1\rho(X_{k+1})italic_ρ ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ) with an abuse of notation (n.b. analogous of ρ(x,t)𝜌𝑥𝑡\rho(x,t)italic_ρ ( italic_x , italic_t ) in the context of SDEs and Fokker-Planck equation). By definition of conditional probability, there exists a function T:Ωn+1+:𝑇superscriptΩ𝑛1subscriptT:\Omega^{n+1}\to\mathbb{R}_{+}italic_T : roman_Ω start_POSTSUPERSCRIPT italic_n + 1 end_POSTSUPERSCRIPT → blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT such that

ρ(Xk+1)=ΩdT(Xk+1|Xk,,X0)ρ(Xk,,X0)i=0ndXi𝜌subscript𝑋𝑘1subscriptsuperscriptΩ𝑑𝑇conditionalsubscript𝑋𝑘1subscript𝑋𝑘subscript𝑋0𝜌subscript𝑋𝑘subscript𝑋0superscriptsubscriptproduct𝑖0𝑛𝑑subscript𝑋𝑖\rho(X_{k+1})=\int_{\Omega^{d}}T(X_{k+1}|X_{k},\dots,X_{0})\rho(X_{k},\dots,X_% {0})\prod_{i=0}^{n}dX_{i}italic_ρ ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ) = ∫ start_POSTSUBSCRIPT roman_Ω start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_T ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT | italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , … , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) italic_ρ ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , … , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) ∏ start_POSTSUBSCRIPT italic_i = 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT italic_d italic_X start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT (4.1)

This equation asserts that any property, uniquely defined by the law ρ(Xk+1)𝜌subscript𝑋𝑘1\rho(X_{k+1})italic_ρ ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ) of the system at time k+1𝑘1{k+1}italic_k + 1, depends on the system’s state at any k0𝑘0k\geq 0italic_k ≥ 0. Generally, this strict constraint is relaxed by imposing Markovianity[stroock2013introduction], which is the property of the transition kernel to depend solely on the present state Xksubscript𝑋𝑘X_{k}italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT and not on previous states, i.e.

T(Xk+1|Xk,,X0)=T(Xk+1|Xk)T(Xk,Xk+1)𝑇conditionalsubscript𝑋𝑘1subscript𝑋𝑘subscript𝑋0𝑇conditionalsubscript𝑋𝑘1subscript𝑋𝑘𝑇subscript𝑋𝑘subscript𝑋𝑘1T(X_{k+1}|X_{k},\dots,X_{0})=T(X_{k+1}|X_{k})\coloneqq T(X_{k},X_{k+1})italic_T ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT | italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , … , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) = italic_T ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT | italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) ≔ italic_T ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ) (4.2)

The sequence (Xk)n0subscript𝑋𝑘𝑛0(X_{k}){n\geq 0}( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) italic_n ≥ 0 is called a Markov chain if the associated transition kernel is Markovian. The question now is how to design such a chain to solve the sampling problem. Traditionally, it is simpler to identify a transition kernel for which ρBG(x)subscript𝜌𝐵𝐺𝑥\rho_{BG}(x)italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) is the unique stationary distribution, i.e., ρ(Xk)=ρBG(x)𝜌subscript𝑋𝑘subscript𝜌𝐵𝐺𝑥\rho(X_{k})=\rho_{BG}(x)italic_ρ ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) = italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) for any n>T𝑛𝑇n>Titalic_n > italic_T in Definition 4.1. Moreover, the integral definition (4.1) is not suitable for applications since one usually evolves Xksubscript𝑋𝑘X_{k}italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT and not its law. Typically, it is required that T𝑇Titalic_T is associated with an explicit time evolution for the process, namely an explicit mapping Xk+1=F(Xk)subscript𝑋𝑘1𝐹subscript𝑋𝑘X_{k+1}=F(X_{k})italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = italic_F ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ).

For historical reasons, let us present the most famous procedure to build the required sampling stochastic process, namely the Metropolis-Hastings algorithm[metropolis1953equation, hastings1970monte]. Such techniques stand out as a foundational Markov chain Monte Carlo (MCMC)[andrieu2003introduction] method. Here, we provide its definition and a sketch of the proof of its properties.

Definition 4.2 (Metropolis-Hastings (MH) algorithm).

Let us consider an initial condition X0ρ0(x)similar-tosubscript𝑋0subscript𝜌0𝑥X_{0}\sim\rho_{0}(x)italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( italic_x ), where ρ0(x)subscript𝜌0𝑥\rho_{0}(x)italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( italic_x ) simple to sample from (e.g. Gaussian or uniform). Let us consider a conditional probability distribution g(Xk+1|Xk)𝑔conditionalsubscript𝑋𝑘1subscript𝑋𝑘g(X_{k+1}|X_{k})italic_g ( italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT | italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ), also called proposal distribution, defined on the state space ΩΩ\Omegaroman_Ω and let ρBG(x)=exp(U(x))/Zsubscript𝜌𝐵𝐺𝑥𝑈𝑥𝑍\rho_{BG}(x)=\exp(-U(x))/Zitalic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) = roman_exp ( - italic_U ( italic_x ) ) / italic_Z the BG ensemble we would like to sample from. Starting at n=0𝑛0n=0italic_n = 0, we define a Markov chain Xksubscript𝑋𝑘X_{k}italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT via the following repeated steps:

  1. 1.

    Given Xksubscript𝑋𝑘X_{k}italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT, generate a proposal Xk+1(p)subscriptsuperscript𝑋𝑝𝑘1X^{(p)}_{k+1}italic_X start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT using the time evolution prescribed by T𝑇Titalic_T.

  2. 2.

    Compute the acceptance ratio

    A(Xk+1(p),Xk)=argmin{1,ρBG(Xk+1(p))g(Xk|Xk+1(p))ρBG(Xk)g(Xk+1(p)|Xk)}𝐴subscriptsuperscript𝑋𝑝𝑘1subscript𝑋𝑘argmin1subscript𝜌𝐵𝐺subscriptsuperscript𝑋𝑝𝑘1𝑔conditionalsubscript𝑋𝑘subscriptsuperscript𝑋𝑝𝑘1subscript𝜌𝐵𝐺subscript𝑋𝑘𝑔conditionalsubscriptsuperscript𝑋𝑝𝑘1subscript𝑋𝑘A(X^{(p)}_{k+1},X_{k})=\operatorname*{arg\,min}\left\{1,\frac{\rho_{BG}(X^{(p)% }_{k+1})g(X_{k}|X^{(p)}_{k+1})}{\rho_{BG}(X_{k})g(X^{(p)}_{k+1}|X_{k})}\right\}italic_A ( italic_X start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) = start_OPERATOR roman_arg roman_min end_OPERATOR { 1 , divide start_ARG italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_X start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ) italic_g ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT | italic_X start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) italic_g ( italic_X start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT | italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) end_ARG } (4.3)
  3. 3.

    Sample a real number u𝒰[0,1]similar-to𝑢𝒰01u\sim\mathcal{U}[0,1]italic_u ∼ caligraphic_U [ 0 , 1 ]. If u<A(Xk,Xk+1(p))𝑢𝐴subscript𝑋𝑘subscriptsuperscript𝑋𝑝𝑘1u<A(X_{k},X^{(p)}_{k+1})italic_u < italic_A ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , italic_X start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT ), accept the proposal and set Xk+1=Xk+1(p)subscript𝑋𝑘1superscriptsubscript𝑋𝑘1𝑝X_{k+1}=X_{k+1}^{(p)}italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( italic_p ) end_POSTSUPERSCRIPT; otherwise, refuse the move and set Xk+1=Xksubscript𝑋𝑘1subscript𝑋𝑘X_{k+1}=X_{k}italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT. Then, increment n𝑛nitalic_n to n+1𝑛1n+1italic_n + 1.

Proposition 4.1.

The Markov chain Xksubscript𝑋𝑘X_{k}italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT defined via MH algorithm has ρBG(x)subscript𝜌𝐵𝐺𝑥\rho_{BG}(x)italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) as unique stationary distribution, i.e.

ρBG(x)=ΩdTMH(x|x)ρBG(x)𝑑x,x,xΩformulae-sequencesubscript𝜌𝐵𝐺𝑥subscriptsuperscriptΩ𝑑subscript𝑇𝑀𝐻conditional𝑥superscript𝑥subscript𝜌𝐵𝐺superscript𝑥differential-dsuperscript𝑥for-all𝑥superscript𝑥Ω\rho_{BG}(x)=\int_{\Omega^{d}}T_{MH}(x|x^{\prime})\rho_{BG}(x^{\prime})dx^{% \prime},\quad\quad\forall x,x^{\prime}\in\Omegaitalic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) = ∫ start_POSTSUBSCRIPT roman_Ω start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_T start_POSTSUBSCRIPT italic_M italic_H end_POSTSUBSCRIPT ( italic_x | italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) italic_d italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT , ∀ italic_x , italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∈ roman_Ω (4.4)

where TMH(x|x)subscript𝑇𝑀𝐻conditional𝑥superscript𝑥T_{MH}(x|x^{\prime})italic_T start_POSTSUBSCRIPT italic_M italic_H end_POSTSUBSCRIPT ( italic_x | italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) is the transition kernel of MH algorithm.

Proof.

We have show that (1) ρBG(x)subscript𝜌𝐵𝐺𝑥\rho_{BG}(x)italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) is a stationary distribution and (2) it is unique. Regarding (2) we advocate to geometric ergodicity[mengersen1996rates]. We present the proof of property (1): firstly, it is equivalent to detailed balance condition[robert1999monte]

ρBG(x)TMH(x,x)=ρBG(x)TMH(x,x)x,xΩformulae-sequencesubscript𝜌𝐵𝐺𝑥subscript𝑇𝑀𝐻𝑥superscript𝑥subscript𝜌𝐵𝐺superscript𝑥subscript𝑇𝑀𝐻superscript𝑥𝑥for-all𝑥superscript𝑥Ω\rho_{BG}(x)T_{MH}(x,x^{\prime})=\rho_{BG}(x^{\prime})T_{MH}(x^{\prime},x)% \quad\quad\forall x,x^{\prime}\in\Omegaitalic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) italic_T start_POSTSUBSCRIPT italic_M italic_H end_POSTSUBSCRIPT ( italic_x , italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) = italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) italic_T start_POSTSUBSCRIPT italic_M italic_H end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT , italic_x ) ∀ italic_x , italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∈ roman_Ω (4.5)

The transition kernel is by definition

TMH(x,x)=g(x|x)A(x,x)+δ(xx)(1ΩA(x,s)g(s|x)𝑑s)subscript𝑇𝑀𝐻𝑥superscript𝑥𝑔conditionalsuperscript𝑥𝑥𝐴superscript𝑥𝑥𝛿𝑥superscript𝑥1subscriptΩ𝐴𝑥𝑠𝑔conditional𝑠𝑥differential-d𝑠T_{MH}(x,x^{\prime})=g(x^{\prime}|x)A(x^{\prime},x)+\delta(x-x^{\prime})\left(% 1-\int_{\Omega}A(x,s)g(s|x)ds\right)italic_T start_POSTSUBSCRIPT italic_M italic_H end_POSTSUBSCRIPT ( italic_x , italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) = italic_g ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | italic_x ) italic_A ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT , italic_x ) + italic_δ ( italic_x - italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) ( 1 - ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_A ( italic_x , italic_s ) italic_g ( italic_s | italic_x ) italic_d italic_s ) (4.6)

where the first addend takes into account the case of accepted move, while the second of the rejected one. Actually, for x=x𝑥superscript𝑥x=x^{\prime}italic_x = italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT the detailed balance condition is trivially true. Then, for xx𝑥superscript𝑥x\neq x^{\prime}italic_x ≠ italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT we compute the left hand side of (4.5)

ρBG(x)TMH(x,x)subscript𝜌𝐵𝐺𝑥subscript𝑇𝑀𝐻𝑥superscript𝑥\displaystyle\rho_{BG}(x)T_{MH}(x,x^{\prime})italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) italic_T start_POSTSUBSCRIPT italic_M italic_H end_POSTSUBSCRIPT ( italic_x , italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) =ρBG(x)g(x|x)A(x,x)absentsubscript𝜌𝐵𝐺𝑥𝑔conditionalsuperscript𝑥𝑥𝐴superscript𝑥𝑥\displaystyle=\rho_{BG}(x)g(x^{\prime}|x)A(x^{\prime},x)= italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) italic_g ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | italic_x ) italic_A ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT , italic_x ) (4.7)
=ρBG(x)g(x|x)argmin{1,ρBG(x)g(x|x)ρBG(x)g(x|x)}absentsubscript𝜌𝐵𝐺𝑥𝑔conditionalsuperscript𝑥𝑥argmin1subscript𝜌𝐵𝐺superscript𝑥𝑔conditional𝑥superscript𝑥subscript𝜌𝐵𝐺𝑥𝑔conditionalsuperscript𝑥𝑥\displaystyle=\rho_{BG}(x)g(x^{\prime}|x)\operatorname*{arg\,min}\left\{1,% \frac{\rho_{BG}(x^{\prime})g(x|x^{\prime})}{\rho_{BG}(x)g(x^{\prime}|x)}\right\}= italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) italic_g ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | italic_x ) start_OPERATOR roman_arg roman_min end_OPERATOR { 1 , divide start_ARG italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) italic_g ( italic_x | italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) end_ARG start_ARG italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) italic_g ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | italic_x ) end_ARG }
=argmin{ρBG(x)g(x|x),ρBG(x)g(x|x)}absentargminsubscript𝜌𝐵𝐺𝑥𝑔conditionalsuperscript𝑥𝑥subscript𝜌𝐵𝐺superscript𝑥𝑔conditional𝑥superscript𝑥\displaystyle=\operatorname*{arg\,min}\left\{\rho_{BG}(x)g(x^{\prime}|x),\rho_% {BG}(x^{\prime})g(x|x^{\prime})\right\}= start_OPERATOR roman_arg roman_min end_OPERATOR { italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ) italic_g ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT | italic_x ) , italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) italic_g ( italic_x | italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ) }

The right hand side is symmetric with respect to swap of x𝑥xitalic_x with xsuperscript𝑥x^{\prime}italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT, hence concluding the proof. ∎

In practice, convergence is considered achieved when the acceptance ratio is consistently close to 1111. In such cases, every newly generated proposal can be regarded as an independent sample obtained from ρBGsubscript𝜌𝐵𝐺\rho_{BG}italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT.

Despite its popularity, the Metropolis-Hastings algorithm has some limitations. It is sensitive to the choice of the proposal distribution g𝑔gitalic_g and its parameters, and improper tuning may result in inefficient exploration. For instance, in the so-called random walk setting, g𝑔gitalic_g is chosen to be a Gaussian transition kernel, and its variance is a critical hyperparameter in this case. Moreover, the algorithm generates correlated samples, impacting the independence of successive samples and hindering accurate estimation even after convergence. Convergence may be slow in high-dimensional spaces, requiring numerous iterations. In such setups, the algorithm’s performance is influenced by the initial state, and initial points far from the basin of the target may impede efficient exploration, leading to an acceptance rate close to zero. Another issue pertains to multimodal distributions, especially those with widely separated modes. They pose a significant challenge for the Metropolis-Hastings algorithm because, depending on the choice of g𝑔gitalic_g, jumps between modes can be very rare and may necessitate a very long chain to practically observe convergence.
The second class of Markov chain we would like to review are the Langevin-based algorithms. The basic idea is very close to the definition of naive score-based diffusion in Proposition 3.3. For the sake of simplicity let us fix the state space Ω=dΩsuperscript𝑑\Omega=\mathbb{R}^{d}roman_Ω = blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT.

Proposition 4.2.

Let us denote with dWt𝑑subscript𝑊𝑡dW_{t}italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT a Wiener process. Under Assumption 2.1, namely

a+and a compact set 𝒞d:xU(x)a|x|2xd𝒞,:𝑎subscriptand a compact set 𝒞dformulae-sequence𝑥𝑈𝑥𝑎superscript𝑥2for-all𝑥superscript𝑑𝒞\exists a\in\mathbb{R}_{+}\text{and a compact set $\mathcal{C}\in\mathbb{R}^{d% }$}:\ x\cdot\nabla U(x)\geq a|x|^{2}\quad\forall x\in\mathbb{R}^{d}\setminus{% \mathcal{C}},∃ italic_a ∈ blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT and a compact set caligraphic_C ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT : italic_x ⋅ ∇ italic_U ( italic_x ) ≥ italic_a | italic_x | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ∀ italic_x ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ∖ caligraphic_C , (4.8)

the Langevin SDE

dXt=U(x)dt+2dWtX0ρ0formulae-sequence𝑑subscript𝑋𝑡𝑈𝑥𝑑𝑡2𝑑subscript𝑊𝑡similar-tosubscript𝑋0subscript𝜌0dX_{t}=-\nabla U(x)dt+\sqrt{2}dW_{t}\quad\quad X_{0}\sim\rho_{0}italic_d italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = - ∇ italic_U ( italic_x ) italic_d italic_t + square-root start_ARG 2 end_ARG italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT (4.9)

have a global solution in law and is ergodic [oksendal2003stochastic, mattingly2002stochastic, talay1900expansion]. For any initial condition ρ0(x)subscript𝜌0𝑥\rho_{0}(x)italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( italic_x ) such solution is ρBG(x)subscript𝜌𝐵𝐺𝑥\rho_{BG}(x)italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT ( italic_x ).

Given this result, one can define a Markov chain based on the time discretization of such SDE and use it for sampling[parisi1981correlation]. Such procedure is commonly named Unadjusted Langevin Algorithm (ULA)[roberts1996exponential].

Definition 4.3 (ULA).

Given a time step h>00h>0italic_h > 0 and a set of i.i.d. gaussian variables {ξk}𝒩(𝟎d,𝐈d)similar-tosubscript𝜉𝑘𝒩subscript0𝑑subscript𝐈𝑑\{\xi_{k}\}\sim\mathcal{N}(\boldsymbol{0}_{d},\boldsymbol{I}_{d}){ italic_ξ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT } ∼ caligraphic_N ( bold_0 start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT , bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT ), the Unadjusted Langevin Algorithm (ULA) is the Markov chain defined as

Xk+1=XkhUθk(Xk)+2hξk,X0ρθ0,formulae-sequencesubscript𝑋𝑘1subscript𝑋𝑘subscript𝑈subscript𝜃𝑘subscript𝑋𝑘2subscript𝜉𝑘similar-tosubscript𝑋0subscript𝜌subscript𝜃0X_{k+1}=X_{k}-h\nabla U_{\theta_{k}}(X_{k})+\sqrt{2h}\,\xi_{k},\quad\quad\quad% \quad X_{0}\sim\rho_{\theta_{0}},italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT - italic_h ∇ italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) + square-root start_ARG 2 italic_h end_ARG italic_ξ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT end_POSTSUBSCRIPT , (4.10)

for k𝑘k\in\mathbb{N}italic_k ∈ blackboard_N.

Under Assumption 2.1, the Unadjusted Langevin Algorithm (ULA) is ergodic and possesses a unique global solution. An advantage over the Metropolis-Hastings (MH) algorithm is that the chain is uniquely defined via U(x)𝑈𝑥U(x)italic_U ( italic_x ), and no proposal distribution is necessary. However, it is well-known that ULA represents a biased implementation of Langevin dynamics[wibisono2018sampling]. For a nonzero time step, the global solution is ρbiasρBGsubscript𝜌𝑏𝑖𝑎𝑠subscript𝜌𝐵𝐺\rho_{bias}\neq\rho_{BG}italic_ρ start_POSTSUBSCRIPT italic_b italic_i italic_a italic_s end_POSTSUBSCRIPT ≠ italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT. Let us illustrate this point with a simple example.

Example 4.1.

Let U(x)=(xμ)TΣ1(xμ)/2+log[det(2πΣ)]/2𝑈𝑥superscript𝑥𝜇𝑇superscriptΣ1𝑥𝜇2det2𝜋Σ2U(x)=(x-\mu)^{T}\Sigma^{-1}(x-\mu)/2+\log[\operatorname{det}(2\pi\Sigma)]/2italic_U ( italic_x ) = ( italic_x - italic_μ ) start_POSTSUPERSCRIPT italic_T end_POSTSUPERSCRIPT roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_x - italic_μ ) / 2 + roman_log [ roman_det ( 2 italic_π roman_Σ ) ] / 2, that is BG ensemble is a gaussian with mean μ𝜇\muitalic_μ and covariance matrix ΣΣ\Sigmaroman_Σ. The associated Langevin SDE is also known as Ornstein-Uhlenbeck (OU) process[uhlenbeck1930theory], having a linear drift as peculiarity:

dXt=Σ1(Xtμ)dt+2dWt.𝑑subscript𝑋𝑡superscriptΣ1subscript𝑋𝑡𝜇𝑑𝑡2𝑑subscript𝑊𝑡dX_{t}=-\Sigma^{-1}(X_{t}-\mu)dt+\sqrt{2}dW_{t}.italic_d italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT = - roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ( italic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT - italic_μ ) italic_d italic_t + square-root start_ARG 2 end_ARG italic_d italic_W start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT . (4.11)

It is possible to write an explicit solution using Ito integral, namely

XtμetΣ1(X0μ)+Σ12(𝑰de2tΣ1)12Zsimilar-tosubscript𝑋𝑡𝜇superscript𝑒𝑡superscriptΣ1subscript𝑋0𝜇superscriptΣ12superscriptsubscript𝑰𝑑superscript𝑒2𝑡superscriptΣ112𝑍X_{t}-\mu\sim e^{-t\Sigma^{-1}}\left(X_{0}-\mu\right)+\Sigma^{\frac{1}{2}}% \left(\boldsymbol{I}_{d}-e^{-2t\Sigma^{-1}}\right)^{\frac{1}{2}}Zitalic_X start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT - italic_μ ∼ italic_e start_POSTSUPERSCRIPT - italic_t roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT end_POSTSUPERSCRIPT ( italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT - italic_μ ) + roman_Σ start_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_e start_POSTSUPERSCRIPT - 2 italic_t roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT italic_Z (4.12)

for any t0𝑡0t\geq 0italic_t ≥ 0 and where Z𝒩(𝟎d,𝐈d)similar-to𝑍𝒩subscript0𝑑subscript𝐈𝑑Z\sim\mathcal{N}(\boldsymbol{0}_{d},\boldsymbol{I}_{d})italic_Z ∼ caligraphic_N ( bold_0 start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT , bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT ) indipendently from X0subscript𝑋0X_{0}italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT. It means that the law of the process converges exponentially fast to 𝒩(μ,Σ)𝒩𝜇Σ\mathcal{N}(\mu,\Sigma)caligraphic_N ( italic_μ , roman_Σ ). The associated ULA is

Xk+1μ=(𝑰dhΣ1)(Xkμ)+2hξk.subscript𝑋𝑘1𝜇subscript𝑰𝑑superscriptΣ1subscript𝑋𝑘𝜇2subscript𝜉𝑘X_{k+1}-\mu=\left(\boldsymbol{I}_{d}-h\Sigma^{-1}\right)\left(X_{k}-\mu\right)% +\sqrt{2h}\xi_{k}.italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT - italic_μ = ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_h roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ) ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT - italic_μ ) + square-root start_ARG 2 italic_h end_ARG italic_ξ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT . (4.13)

and the corresponding solution in law is

XkμAhk(X0μ)+2h(𝑰dAh2)12(𝑰dAh2k)12Zsimilar-tosubscript𝑋𝑘𝜇superscriptsubscript𝐴𝑘subscript𝑋0𝜇2superscriptsubscript𝑰𝑑superscriptsubscript𝐴212superscriptsubscript𝑰𝑑superscriptsubscript𝐴2𝑘12𝑍X_{k}-\mu\sim A_{h}^{k}\left(X_{0}-\mu\right)+\sqrt{2h}\left(\boldsymbol{I}_{d% }-A_{h}^{2}\right)^{-\frac{1}{2}}\left(\boldsymbol{I}_{d}-A_{h}^{2k}\right)^{% \frac{1}{2}}Zitalic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT - italic_μ ∼ italic_A start_POSTSUBSCRIPT italic_h end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_k end_POSTSUPERSCRIPT ( italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT - italic_μ ) + square-root start_ARG 2 italic_h end_ARG ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_A start_POSTSUBSCRIPT italic_h end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT - divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_A start_POSTSUBSCRIPT italic_h end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 2 italic_k end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT italic_Z (4.14)

where Ah=𝐈dhΣ1subscript𝐴subscript𝐈𝑑superscriptΣ1A_{h}=\boldsymbol{I}_{d}-h\Sigma^{-1}italic_A start_POSTSUBSCRIPT italic_h end_POSTSUBSCRIPT = bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_h roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT. Naming λmin(Σ)>0subscript𝜆𝑚𝑖𝑛Σ0\lambda_{min}(\Sigma)>0italic_λ start_POSTSUBSCRIPT italic_m italic_i italic_n end_POSTSUBSCRIPT ( roman_Σ ) > 0 the minimum eigenvalue of the covariance matrix, for 0<h<λmin(Σ)0subscript𝜆𝑚𝑖𝑛Σ0<h<\lambda_{min}(\Sigma)0 < italic_h < italic_λ start_POSTSUBSCRIPT italic_m italic_i italic_n end_POSTSUBSCRIPT ( roman_Σ ) we have limkAhk=0subscript𝑘superscriptsubscript𝐴𝑘0\lim_{k\to\infty}A_{h}^{k}=0roman_lim start_POSTSUBSCRIPT italic_k → ∞ end_POSTSUBSCRIPT italic_A start_POSTSUBSCRIPT italic_h end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_k end_POSTSUPERSCRIPT = 0. Thus, for k𝑘k\to\inftyitalic_k → ∞

Xk𝑑μ+2h(𝑰dAh2)12Z𝑑subscript𝑋𝑘𝜇2superscriptsubscript𝑰𝑑superscriptsubscript𝐴212𝑍X_{k}\xrightarrow{d}\mu+\sqrt{2h}\left(\boldsymbol{I}_{d}-A_{h}^{2}\right)^{-% \frac{1}{2}}Zitalic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT start_ARROW overitalic_d → end_ARROW italic_μ + square-root start_ARG 2 italic_h end_ARG ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_A start_POSTSUBSCRIPT italic_h end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT - divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT italic_Z (4.15)

This means that the limiting measure for ULA is not ρBGsubscript𝜌𝐵𝐺\rho_{BG}italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT, but

ρbias(x)=𝒩(μ,Σ(𝑰dh2Σ1)1)(x)subscript𝜌𝑏𝑖𝑎𝑠𝑥𝒩𝜇Σsuperscriptsubscript𝑰𝑑2superscriptΣ11𝑥\rho_{bias}(x)=\mathcal{N}\left(\mu,\Sigma\left(\boldsymbol{I}_{d}-\frac{h}{2}% \Sigma^{-1}\right)^{-1}\right)(x)italic_ρ start_POSTSUBSCRIPT italic_b italic_i italic_a italic_s end_POSTSUBSCRIPT ( italic_x ) = caligraphic_N ( italic_μ , roman_Σ ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - divide start_ARG italic_h end_ARG start_ARG 2 end_ARG roman_Σ start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ) ( italic_x ) (4.16)

This example illustrates that the Unadjusted Langevin Algorithm (ULA) exhibits bias even for a very simple target density. This phenomenon has been recently analyzed mathematically[wibisono2018sampling]. The physical interpretation is that detailed balance is broken by construction. Let us elaborate on this point: in Proposition 3.2, we demonstrated how a Stochastic Differential Equation (SDE) can be associated with a Partial Differential Equation (PDE). The specific case studied in this section was previously analyzed in Proposition 3.3. Specifically, the Boltzmann-Gibbs (BG) density is the unique minimizer of the Kullback-Leibler (KL) divergence functional DKL(ρρGB)subscript𝐷KLconditional𝜌subscript𝜌𝐺𝐵D_{\text{KL}}(\rho\parallel\rho_{GB})italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ ∥ italic_ρ start_POSTSUBSCRIPT italic_G italic_B end_POSTSUBSCRIPT ). Moreover, the Fokker-Plank PDE corresponds to the gradient flow in 𝒫(d)𝒫superscript𝑑\mathcal{P}(\mathbb{R}^{d})caligraphic_P ( blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT ) with respect to the 2-Wasserstein distance 𝒲2subscript𝒲2\mathcal{W}_{2}caligraphic_W start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT[jordan1998variational]. If we split (4.10) in two substeps

Xk+12=XkhU(Xk)Xk+1=Xk+12+2εξksubscript𝑋𝑘12subscript𝑋𝑘𝑈subscript𝑋𝑘subscript𝑋𝑘1subscript𝑋𝑘122𝜀subscript𝜉𝑘\begin{split}X_{k+\frac{1}{2}}&=X_{k}-h\nabla U(X_{k})\\ X_{k+1}&=X_{k+\frac{1}{2}}+\sqrt{2\varepsilon}\xi_{k}\end{split}start_ROW start_CELL italic_X start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT end_CELL start_CELL = italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT - italic_h ∇ italic_U ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) end_CELL end_ROW start_ROW start_CELL italic_X start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT end_CELL start_CELL = italic_X start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT + square-root start_ARG 2 italic_ε end_ARG italic_ξ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_CELL end_ROW (4.17)

we can associate each of them to a precise operation in probability space. In particular, denoting with ρisubscript𝜌𝑖\rho_{i}italic_ρ start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT the law of Xisubscript𝑋𝑖X_{i}italic_X start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, we obtain

ρk+12=(𝑰dhU)#ρkρk+1=𝒩(𝟎d,2h𝑰d)ρk+12subscript𝜌𝑘12subscriptsubscript𝑰𝑑𝑈#subscript𝜌𝑘subscript𝜌𝑘1𝒩subscript0𝑑2subscript𝑰𝑑subscript𝜌𝑘12\begin{split}\rho_{k+\frac{1}{2}}&=(\boldsymbol{I}_{d}-h\nabla U)_{\#}\rho_{k}% \\ \rho_{k+1}&=\mathcal{N}(\boldsymbol{0}_{d},2h\boldsymbol{I}_{d})\star\rho_{k+% \frac{1}{2}}\end{split}start_ROW start_CELL italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT end_CELL start_CELL = ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_h ∇ italic_U ) start_POSTSUBSCRIPT # end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_CELL end_ROW start_ROW start_CELL italic_ρ start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT end_CELL start_CELL = caligraphic_N ( bold_0 start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT , 2 italic_h bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT ) ⋆ italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT end_CELL end_ROW (4.18)

We recall the decomposition of the Kullback-Leibler (KL) divergence as DKL(ρρGB)=H(ρ,ρGB)H(ρ)subscript𝐷KLconditional𝜌subscript𝜌𝐺𝐵𝐻𝜌subscript𝜌𝐺𝐵𝐻𝜌D_{\text{KL}}(\rho\parallel\rho_{GB})=-H(\rho,\rho_{GB})-H(\rho)italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ ∥ italic_ρ start_POSTSUBSCRIPT italic_G italic_B end_POSTSUBSCRIPT ) = - italic_H ( italic_ρ , italic_ρ start_POSTSUBSCRIPT italic_G italic_B end_POSTSUBSCRIPT ) - italic_H ( italic_ρ ). In (4.18), the first step involves the forward discretization of gradient descent on H(ρ,ρGB)=𝔼ρ[U]𝐻𝜌subscript𝜌𝐺𝐵subscript𝔼𝜌delimited-[]𝑈-H(\rho,\rho_{GB})=\mathbb{E}_{\rho}[U]- italic_H ( italic_ρ , italic_ρ start_POSTSUBSCRIPT italic_G italic_B end_POSTSUBSCRIPT ) = blackboard_E start_POSTSUBSCRIPT italic_ρ end_POSTSUBSCRIPT [ italic_U ], while the second step represents the exact gradient flow for negative entropy in probability space. Therefore, ULA is also referred to as the Forward-Flow method in probability space. The bias arises because the forward gradient descent does not correspond, in probability space, to the adjoint of the flow at iteration k+1/2𝑘12k+1/2italic_k + 1 / 2. One possible solution is to use forward-backward combinations, referring to proximal algorithms[parikh2014proximal]. In particular, the Forward-Backward (FB) implementation for Langevin dynamics would be

ρk+12=(𝑰dhU)#ρkρk+1=argminρ𝒫{H(ρ)+12ϵ𝒲2(ρ,ρk+12)2}subscript𝜌𝑘12subscriptsubscript𝑰𝑑𝑈#subscript𝜌𝑘subscript𝜌𝑘1subscriptargmin𝜌𝒫𝐻𝜌12italic-ϵsubscript𝒲2superscript𝜌subscript𝜌𝑘122\begin{split}\rho_{k+\frac{1}{2}}&=(\boldsymbol{I}_{d}-h\nabla U)_{\#}\rho_{k}% \\ \rho_{k+1}&=\operatorname*{arg\,min}_{\rho\in\mathcal{P}}\left\{-H(\rho)+\frac% {1}{2\epsilon}\mathcal{W}_{2}\left(\rho,\rho_{k+\frac{1}{2}}\right)^{2}\right% \}\end{split}start_ROW start_CELL italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT end_CELL start_CELL = ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT - italic_h ∇ italic_U ) start_POSTSUBSCRIPT # end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_CELL end_ROW start_ROW start_CELL italic_ρ start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT end_CELL start_CELL = start_OPERATOR roman_arg roman_min end_OPERATOR start_POSTSUBSCRIPT italic_ρ ∈ caligraphic_P end_POSTSUBSCRIPT { - italic_H ( italic_ρ ) + divide start_ARG 1 end_ARG start_ARG 2 italic_ϵ end_ARG caligraphic_W start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ( italic_ρ , italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT } end_CELL end_ROW (4.19)

Similarly, the Backward-Forward (BF) version

ρk+12subscript𝜌𝑘12\displaystyle\rho_{k+\frac{1}{2}}italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT =((𝑰d+hU)1)#ρkabsentsubscriptsuperscriptsubscript𝑰𝑑𝑈1#subscript𝜌𝑘\displaystyle=\left((\boldsymbol{I}_{d}+h\nabla U)^{-1}\right)_{\#}\rho_{k}= ( ( bold_italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT + italic_h ∇ italic_U ) start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT # end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT (4.20)
ρk+1subscript𝜌𝑘1\displaystyle\rho_{k+1}italic_ρ start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT =expρk+12(hlogρk+12)absentsubscriptsubscript𝜌𝑘12subscript𝜌𝑘12\displaystyle=\exp_{\rho_{k+\frac{1}{2}}}\left(-h\nabla\log\rho_{k+\frac{1}{2}% }\right)= roman_exp start_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( - italic_h ∇ roman_log italic_ρ start_POSTSUBSCRIPT italic_k + divide start_ARG 1 end_ARG start_ARG 2 end_ARG end_POSTSUBSCRIPT )

where exp\exproman_exp is the exponential map. Unfortunately, both FB and BF are not implementable in practice, except for the trivial case of gaussian initial data and target ρBGsubscript𝜌𝐵𝐺\rho_{BG}italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT. The heat flow (the step k+1/2𝑘12k+1/2italic_k + 1 / 2) is the most problematic since it concerns steps in probability space. Neither forward (n.b. beyond one iteration) nor backward are usable. As a side note, one could imagine to directly perform a single forward or backward step on the KL divergence. Unfortunately, the encountered issues are the same one has for the heat flow, i.e. the hard task appears to be the actual implementation of forward or backward routines in probability space. In conclusion, ULA appears to be the simplest time discretization of Langevin dynamics, since it is practically implementable in general, hence very used for sampling from a BG ensemble. However, it is known to be biased and other methods are studied to eliminate, or at least reduce, such bias.
One possibility we would like to review is Metropolis Adjusted Langevin Algorithm[grenander1994representations] (MALA), which represents a sort of hybrid between MH and ULA.

Definition 4.4 (MALA).

Metropolis Adjusted Langevin Algorithm is a particular case of MH algorithm 4.2 where the proposal distribution is the transition kernel associated to ULA (4.10), namely (for xd𝑥superscript𝑑x\in\mathbb{R}^{d}italic_x ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT)

g(xx)=1(2πh)d2exp(14hxx+hU(x)22)𝑔conditionalsuperscript𝑥𝑥1superscript2𝜋𝑑214superscriptsubscriptnormsuperscript𝑥𝑥𝑈𝑥22{\displaystyle g(x^{\prime}\mid x)=\frac{1}{(2\pi h)^{\frac{d}{2}}}\exp\left(-% {\frac{1}{4h}}\|x^{\prime}-x+hU(x)\|_{2}^{2}\right)}italic_g ( italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ∣ italic_x ) = divide start_ARG 1 end_ARG start_ARG ( 2 italic_π italic_h ) start_POSTSUPERSCRIPT divide start_ARG italic_d end_ARG start_ARG 2 end_ARG end_POSTSUPERSCRIPT end_ARG roman_exp ( - divide start_ARG 1 end_ARG start_ARG 4 italic_h end_ARG ∥ italic_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT - italic_x + italic_h italic_U ( italic_x ) ∥ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) (4.21)

On the other hand, one can interpret MALA as a corrective measure for the breakdown of detailed balance in ULA. While the Metropolis-Hastings algorithm inherently respects detailed balance, implying that MALA becomes asymptotically unbiased for a large number of iterations as k𝑘k\to\inftyitalic_k → ∞, certain challenges persist. A primary concern is the sensitivity to the choice of the step size hhitalic_h during the discretization of Langevin dynamics, significantly influencing the efficiency of sampling. When hhitalic_h is too small, it can lead to poor exploration and potentially a very low acceptance rate, while an excessively large hhitalic_h can lead to instability of the chain. Determining an optimal hhitalic_h lacks a general rule, contributing to MALA introducing bias in samples, particularly evident when the target distribution features sharp peaks or multimodal structures. This bias introduces potential inaccuracies in statistical estimates.

In practical applications, MALA may exhibit random walk behavior, especially when step sizes are inadequately tuned, resulting in inefficient exploration and sluggish convergence. The algorithm’s performance is further contingent on the choice of initial conditions, and beginning far from high-probability regions may necessitate a considerable number of iterations for meaningful exploration. Additionally, MALA may struggle to adapt to changes in the geometry of the target distribution, particularly when facing varying curvatures or strong anisotropy.

While various more advanced algorithms exist, they often build upon the foundational concepts discussed in this section. Notable among them is Hamiltonian (or Hybrid) Monte Carlo[duane1987hybrid] (HMC), an advanced MCMC method inspired by Hamiltonian mechanics. HMC utilizes fictitious Hamiltonian dynamics to propose new states, enhancing exploration, especially in high-dimensional systems. Gibbs sampling[geman1984stochastic], another MCMC approach, iteratively samples from conditional distributions given current variable values on a single dimension, proving effective, particularly in high-dimensional spaces. Parallel Tempering, or Replica Exchange[swendsen1986replica], involves running multiple chains at different temperatures concurrently, with periodic swaps between neighboring chains to facilitate improved exploration.

In general, most methods aim to find a chain that produces independent samples from a Boltzmann-Gibbs ensemble, particularly when run for extended periods. A critical issue is measuring the effective bias due to the truncation at finite time of the chain, posing challenges for convergence towards the asymptotic ρBGsubscript𝜌𝐵𝐺\rho_{BG}italic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT. Unfortunately, few general results are available, and they are often limited to specific BG ensembles, such as Gaussian or log-concave densities. This becomes particularly problematic in the context of Energy-Based Models (EBM), as outlined in Remark 2.2, where sampling from a BG distribution is required at each step of parameter optimization.

5 EBMs and physics

In this section, we provide a review of the Boltzmann-Gibbs ensemble in relation to Statistical Physics, covering its derivation in equilibrium. The purpose of this treatment is to motivate the specific structure of EBMs, which could be particularly useful for reader’s not familiar with Statistical Ensembles.

The first step involves the derivation of the Boltzmann-Gibbs ensemble. Here, we present a derivation based on information theory[jaynes1957information, jaynes1957information2], offering a posteriori physical interpretation of the quantities we will manipulate. Alternative methods of proof are also available[gallavotti1999statistical]. Consider a physical system whose state is uniquely determined by a variable xΩd𝑥Ωsuperscript𝑑x\in\Omega\subseteq\mathbb{R}^{d}italic_x ∈ roman_Ω ⊆ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, where ΩΩ\Omegaroman_Ω is often referred to as phase space. The connection with information theory is linked to the fundamental problem of Statistical Physics: describing a system as a statistical ensemble, i.e., identifying an observation of x𝑥xitalic_x as a sample from an underlying PDF ρ𝜌\rhoitalic_ρ. Like classical statistics, ρ𝜌\rhoitalic_ρ contains a wealth of information about the system, particularly its global properties.

In Physics, this dichotomy translates into the microscopic versus macroscopic realms. Let’s envision a simple thought experiment: picture a large city where each of the N𝑁Nitalic_N inhabitants is given a fair coin, with the coin’s state represented by our variable x{1,1}N𝑥superscript11𝑁x\in\{-1,1\}^{N}italic_x ∈ { - 1 , 1 } start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT. Twice a day, everyone has to flip their coin. If we were omniscient, there would be a way to predict the state x𝑥xitalic_x with no error (i.e., the microscopic state) and derive any global (macroscopic) property, such as the sum or product of the state values at each flipping event, with no error. However, in reality, nobody could achieve this; we rely on statistics, the central limit theorem, and so forth. In other words, we know the probability density ρ(x)𝜌𝑥\rho(x)italic_ρ ( italic_x ) from which the process is a sampled event. For instance, if N𝑁Nitalic_N is large enough, we expect the average of the state vector to be 00 for any flipping event, and we can deduce so directly from ρ𝜌\rhoitalic_ρ.

In Statistical Physics, each coin represents a component of a system, such as a particle in a gas, for which a direct measurement of x𝑥xitalic_x is unattainable. The goal is to determine ρ𝜌\rhoitalic_ρ so that standard statistical tools can be used to analyze global properties. The challenge that makes Statistical Physics more complex than the simple example above is that the dynamics of individual components can be unknown and inaccessible. Additionally, interactions between components can make the identification of ρ𝜌\rhoitalic_ρ challenging, even if the underlying microscopic dynamics are known.

To address this issue, we recognize that, before formulating any physical model, we need some motivated assumptions—constraints or information—regarding how the system should behave, at least on a macroscopic level. This is the bare minimum; without any information about a system, it is impossible to provide any meaningful analysis. Thus, adopting a claim of epistemic modesty, one can state that we aim to select the model compatible with such constraints that maximizes our ignorance about the system. The mathematical translation of such idea is the Principle of Maximum Entropy.

Assumption 5.1 (Principle of Maximum Entropy).

Let us consider the unknown ρ:Ω+:𝜌Ωsubscript\rho:\Omega\to\mathbb{R}_{+}italic_ρ : roman_Ω → blackboard_R start_POSTSUBSCRIPT + end_POSTSUBSCRIPT that describes the probability distribution of the states. We assume ρ𝜌\rhoitalic_ρ to be absolutely continuous w.r.t. Lebesgue measure without loss of generality. Given a vector field F:Ωd:𝐹Ωsuperscript𝑑F:\Omega\to\mathbb{R}^{d}italic_F : roman_Ω → blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT, ΛdΛsuperscript𝑑\Lambda\in\mathbb{R}^{d}roman_Λ ∈ blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT and a PDF π𝜋\piitalic_π, a set of constraints is any component-wise (in)equality

Ik[π]ΩFk(x)π(x)𝑑xkΛkk=1,,dformulae-sequencesubscript𝐼𝑘delimited-[]𝜋subscriptΩsubscript𝐹𝑘𝑥𝜋𝑥differential-d𝑥subscript𝑘subscriptΛ𝑘𝑘1𝑑I_{k}[\pi]\coloneqq\int_{\Omega}F_{k}(x)\pi(x)dx\leq_{k}\Lambda_{k}\quad\quad k% =1,\dots,ditalic_I start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT [ italic_π ] ≔ ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_F start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ( italic_x ) italic_π ( italic_x ) italic_d italic_x ≤ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT roman_Λ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT italic_k = 1 , … , italic_d (5.1)

where the symbol ksubscript𝑘\leq_{k}≤ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT can be an equality or inequality. The Principle of Maximum Entropy is

ρ=argmaxπ𝒫(Ω)Ik[π]kΛkH(π)𝜌subscriptargmax𝜋𝒫Ωsubscript𝑘subscript𝐼𝑘delimited-[]𝜋subscriptΛ𝑘𝐻𝜋\rho=\operatorname*{arg\,max}_{\begin{subarray}{c}\pi\in\mathcal{P}(\Omega)\\ I_{k}[\pi]\leq_{k}\Lambda_{k}\end{subarray}}H(\pi)italic_ρ = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT start_ARG start_ROW start_CELL italic_π ∈ caligraphic_P ( roman_Ω ) end_CELL end_ROW start_ROW start_CELL italic_I start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT [ italic_π ] ≤ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT roman_Λ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_CELL end_ROW end_ARG end_POSTSUBSCRIPT italic_H ( italic_π ) (5.2)

where H(ρ)𝐻𝜌H(\rho)italic_H ( italic_ρ ) is the usual differential entropy, cfr. (2.7).

This variational formulation identify the "ignorance" about the system with the entropy associated to ρ𝜌\rhoitalic_ρ. It has been proven that the entropy can be characterized in an axiomatic way[aczel1974shannon], so that the definition of differential entropy is unique with respect to certain properties. For the sake of the present treatment, let us motivate the Maximum Principle with a simple example.

Example 5.1 (Maximum principle on an interval).

Let us consider an interval Ω=[a,b]Ω𝑎𝑏\Omega=[a,b]\subset\mathbb{R}roman_Ω = [ italic_a , italic_b ] ⊂ blackboard_R, with Vol(Ω)=ab𝑑xVolΩsuperscriptsubscript𝑎𝑏differential-d𝑥\operatorname{Vol}(\Omega)=\int_{a}^{b}dxroman_Vol ( roman_Ω ) = ∫ start_POSTSUBSCRIPT italic_a end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_b end_POSTSUPERSCRIPT italic_d italic_x. Moreover, the only constraint is that ρ𝜌\rhoitalic_ρ can be normalized and is positive. Thus, we have I0[π]=abρ(x)𝑑x=1subscript𝐼0delimited-[]𝜋superscriptsubscript𝑎𝑏𝜌𝑥differential-d𝑥1I_{0}[\pi]=\int_{a}^{b}\rho(x)dx=1italic_I start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT [ italic_π ] = ∫ start_POSTSUBSCRIPT italic_a end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_b end_POSTSUPERSCRIPT italic_ρ ( italic_x ) italic_d italic_x = 1 and

ρ=argmaxπ𝒫(Ω)I0[π]=1,π>0H(π)𝜌subscriptargmax𝜋𝒫Ωformulae-sequencesubscript𝐼0delimited-[]𝜋1𝜋0𝐻𝜋\rho=\operatorname*{arg\,max}_{\begin{subarray}{c}\pi\in\mathcal{P}(\Omega)\\ I_{0}[\pi]=1,\;\pi>0\end{subarray}}H(\pi)italic_ρ = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT start_ARG start_ROW start_CELL italic_π ∈ caligraphic_P ( roman_Ω ) end_CELL end_ROW start_ROW start_CELL italic_I start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT [ italic_π ] = 1 , italic_π > 0 end_CELL end_ROW end_ARG end_POSTSUBSCRIPT italic_H ( italic_π ) (5.3)

We can use Lagrange multipliers to solve a constrained optimization problem, solving the unconstrained optimization of the Lagrangian

J(π)H(π)+λ0(abπ(x)𝑑x1)𝐽𝜋𝐻𝜋subscript𝜆0superscriptsubscript𝑎𝑏𝜋𝑥differential-d𝑥1J(\pi)\coloneqq H(\pi)+\lambda_{0}\left(\int_{a}^{b}\pi(x)dx-1\right)italic_J ( italic_π ) ≔ italic_H ( italic_π ) + italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( ∫ start_POSTSUBSCRIPT italic_a end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_b end_POSTSUPERSCRIPT italic_π ( italic_x ) italic_d italic_x - 1 ) (5.4)

To find stationary points we can compute the first variational derivative with respect to π𝜋\piitalic_π and finding its roots, namely solutions of

δJ(π)δπ=logπ1+λ0=0𝛿𝐽𝜋𝛿𝜋𝜋1subscript𝜆00\frac{\delta J(\pi)}{\delta\pi}=-\log\pi-1+\lambda_{0}=0divide start_ARG italic_δ italic_J ( italic_π ) end_ARG start_ARG italic_δ italic_π end_ARG = - roman_log italic_π - 1 + italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = 0 (5.5)

that is ρ(x,λ0)=exp(λ01)𝜌𝑥subscript𝜆0subscript𝜆01\rho(x,\lambda_{0})=\exp(\lambda_{0}-1)italic_ρ ( italic_x , italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) = roman_exp ( italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT - 1 ). To find λ0subscript𝜆0\lambda_{0}italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT we can substitute ρ(x,λ0)𝜌𝑥subscript𝜆0\rho(x,\lambda_{0})italic_ρ ( italic_x , italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) into the constraint, yielding λ0=1log(ba)subscript𝜆01𝑏𝑎\lambda_{0}=1-\log(b-a)italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = 1 - roman_log ( italic_b - italic_a ). In conclusion, ρ(x)=1/(ba)𝜌𝑥1𝑏𝑎\rho(x)=1/(b-a)italic_ρ ( italic_x ) = 1 / ( italic_b - italic_a ), which also satisfies the positivity request. We have just to check that such stationary point is a maximum. The second variation of J(π)𝐽𝜋J(\pi)italic_J ( italic_π ) evaluated in the stationary point is

δ2J(π)δπ2|π=ρ=1ρ(x)<0\frac{\delta^{2}J(\pi)}{\delta\pi^{2}}\Bigr{\rvert}_{\pi=\rho}=-\frac{1}{\rho(% x)}<0divide start_ARG italic_δ start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_J ( italic_π ) end_ARG start_ARG italic_δ italic_π start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG | start_POSTSUBSCRIPT italic_π = italic_ρ end_POSTSUBSCRIPT = - divide start_ARG 1 end_ARG start_ARG italic_ρ ( italic_x ) end_ARG < 0 (5.6)

Hence, we conclude that ρ(x)𝜌𝑥\rho(x)italic_ρ ( italic_x ) is a maximum. If ΩΩ\Omegaroman_Ω is discrete such derivation can be easily generalized. The interpretation is straightforward: imagine that ΩΩ\Omegaroman_Ω is the event space for some random process. Without any knowledge, the simplest possible model is the one that associates the same probability to all the possible outcomes.

At this point we have all the ingredients to present the derivation of Boltzmann-Gibbs ensemble.

Proposition 5.1 (Boltzmann-Gibbs ensemble from Maximum Entropy principle).

Given U(x)𝑈𝑥U(x)italic_U ( italic_x ) that satisfies Assumption 2.1 and a constant U¯¯𝑈\bar{U}over¯ start_ARG italic_U end_ARG, the Boltzmann-Gibbs ρBG=eλ1U(x)/Zsubscript𝜌𝐵𝐺superscript𝑒subscript𝜆1𝑈𝑥𝑍\rho_{BG}=e^{\lambda_{1}U(x)}/Zitalic_ρ start_POSTSUBSCRIPT italic_B italic_G end_POSTSUBSCRIPT = italic_e start_POSTSUPERSCRIPT italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT italic_U ( italic_x ) end_POSTSUPERSCRIPT / italic_Z, where λ1>0subscript𝜆10\lambda_{1}>0italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT > 0, is the unique solution of the variational maximization problem (5.2) where the set of constraints is

I0[π]Ωπ(x)𝑑x=1I1[π]ΩU(x)π(x)𝑑x=U¯subscript𝐼0delimited-[]𝜋subscriptΩ𝜋𝑥differential-d𝑥1subscript𝐼1delimited-[]𝜋subscriptΩ𝑈𝑥𝜋𝑥differential-d𝑥¯𝑈\begin{split}I_{0}[\pi]&\coloneqq\int_{\Omega}\pi(x)dx=1\\ I_{1}[\pi]&\coloneqq\int_{\Omega}U(x)\pi(x)dx=\bar{U}\end{split}start_ROW start_CELL italic_I start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT [ italic_π ] end_CELL start_CELL ≔ ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_π ( italic_x ) italic_d italic_x = 1 end_CELL end_ROW start_ROW start_CELL italic_I start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT [ italic_π ] end_CELL start_CELL ≔ ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_U ( italic_x ) italic_π ( italic_x ) italic_d italic_x = over¯ start_ARG italic_U end_ARG end_CELL end_ROW (5.7)
Proof.

The proof proceeds similarly to Example 5.1. The constrained optimization problem (5.2) is associated to the unconstrained one

ρ=argmaxπ𝒫(Ω)J(π)argmaxπ𝒫(Ω)H(π)+λ0(Ωπ(x)𝑑x1)+λ1(ΩU(x)π(x)𝑑xU¯).𝜌subscriptargmax𝜋𝒫Ω𝐽𝜋subscriptargmax𝜋𝒫Ω𝐻𝜋subscript𝜆0subscriptΩ𝜋𝑥differential-d𝑥1subscript𝜆1subscriptΩ𝑈𝑥𝜋𝑥differential-d𝑥¯𝑈\rho=\operatorname*{arg\,max}_{\pi\in\mathcal{P}(\Omega)}J(\pi)\coloneqq% \operatorname*{arg\,max}_{\pi\in\mathcal{P}(\Omega)}H(\pi)+\lambda_{0}\left(% \int_{\Omega}\pi(x)dx-1\right)+\lambda_{1}\left(\int_{\Omega}U(x)\pi(x)dx-\bar% {U}\right).italic_ρ = start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_π ∈ caligraphic_P ( roman_Ω ) end_POSTSUBSCRIPT italic_J ( italic_π ) ≔ start_OPERATOR roman_arg roman_max end_OPERATOR start_POSTSUBSCRIPT italic_π ∈ caligraphic_P ( roman_Ω ) end_POSTSUBSCRIPT italic_H ( italic_π ) + italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ( ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_π ( italic_x ) italic_d italic_x - 1 ) + italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ( ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_U ( italic_x ) italic_π ( italic_x ) italic_d italic_x - over¯ start_ARG italic_U end_ARG ) . (5.8)

where λ0,λ1subscript𝜆0subscript𝜆1\lambda_{0},\lambda_{1}italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT are Lagrange multiplier. We compute the first variational derivative and find its roots

δJ(π)δπ=logπ(x)1+λ0+λ1U(x)=0𝛿𝐽𝜋𝛿𝜋𝜋𝑥1subscript𝜆0subscript𝜆1𝑈𝑥0\frac{\delta J(\pi)}{\delta\pi}=-\log\pi(x)-1+\lambda_{0}+\lambda_{1}U(x)=0divide start_ARG italic_δ italic_J ( italic_π ) end_ARG start_ARG italic_δ italic_π end_ARG = - roman_log italic_π ( italic_x ) - 1 + italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT + italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT italic_U ( italic_x ) = 0 (5.9)

That is, ρ(x)=exp(λ0+λ1U(x)1)𝜌𝑥subscript𝜆0subscript𝜆1𝑈𝑥1\rho(x)=\exp(\lambda_{0}+\lambda_{1}U(x)-1)italic_ρ ( italic_x ) = roman_exp ( italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT + italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT italic_U ( italic_x ) - 1 ). This means that λ0subscript𝜆0\lambda_{0}italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT can be incorporated in the normalization factor, namely the partition function Z1=exp(λ01)superscript𝑍1subscript𝜆01Z^{-1}=\exp(\lambda_{0}-1)italic_Z start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT = roman_exp ( italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT - 1 ), and determined via the constraint I0[ρ]=1subscript𝐼0delimited-[]𝜌1I_{0}[\rho]=1italic_I start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT [ italic_ρ ] = 1. While λ1subscript𝜆1\lambda_{1}italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT is implicitly determined by I1subscript𝐼1I_{1}italic_I start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT. To check that such solution is a maximum, we compute the second variation obtaining a result analogous to (5.6). ∎

The remaining issue is the identification of λ1subscript𝜆1\lambda_{1}italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT with β=1/kBT𝛽1subscript𝑘𝐵𝑇\beta=1/k_{B}Titalic_β = 1 / italic_k start_POSTSUBSCRIPT italic_B end_POSTSUBSCRIPT italic_T, related to temperature T𝑇Titalic_T and Boltzmann dimensional constant kB=1.23×1028JK1subscript𝑘𝐵1.23superscript1028JsuperscriptK1k_{B}=1.23\times 10^{-28}\,\text{J}\cdot\text{K}^{-1}italic_k start_POSTSUBSCRIPT italic_B end_POSTSUBSCRIPT = 1.23 × 10 start_POSTSUPERSCRIPT - 28 end_POSTSUPERSCRIPT J ⋅ K start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT. The reason is that if we interpret the Boltzmann-Gibbs ensemble with an equilibrium ensemble, the derivation via Maximum Entropy principle must be coherent with Thermodynamics[adkins1983equilibrium]. A complete survey on such field would lead the present treatment off-topic. The take home message is related to a different interpretation of the unconstrained optimization problem (5.8), namely

δδπ(H(π)+λ0Ωπ(x)𝑑x+λ1ΩU(x)π(x)𝑑x)=0𝛿𝛿𝜋𝐻𝜋subscript𝜆0subscriptΩ𝜋𝑥differential-d𝑥subscript𝜆1subscriptΩ𝑈𝑥𝜋𝑥differential-d𝑥0\frac{\delta}{\delta\pi}\left(H(\pi)+\lambda_{0}\int_{\Omega}\pi(x)dx+\lambda_% {1}\int_{\Omega}U(x)\pi(x)dx\right)=0divide start_ARG italic_δ end_ARG start_ARG italic_δ italic_π end_ARG ( italic_H ( italic_π ) + italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_π ( italic_x ) italic_d italic_x + italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_U ( italic_x ) italic_π ( italic_x ) italic_d italic_x ) = 0 (5.10)

In particular, the following lemma holds true:

Lemma 5.1.

Maximum Entropy principle and its variational formulation are equivalent to

  • Constrained minimization of energy functional U¯=ΩU(x)π(x)𝑑x¯𝑈subscriptΩ𝑈𝑥𝜋𝑥differential-d𝑥\bar{U}=\int_{\Omega}U(x)\pi(x)dxover¯ start_ARG italic_U end_ARG = ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_U ( italic_x ) italic_π ( italic_x ) italic_d italic_x.

  • Constrained minimization of Helmholtz Free Energy functional F=U¯TH(π)𝐹¯𝑈𝑇𝐻𝜋F=\bar{U}-TH(\pi)italic_F = over¯ start_ARG italic_U end_ARG - italic_T italic_H ( italic_π ), where T>0𝑇0T>0italic_T > 0 is the usual thermodynamic temperature.

Proof.

The proof is just related to a redefinition of the Lagrange multipliers. For the minimization of energy, one define λ1=1/λ1subscriptsuperscript𝜆11subscript𝜆1\lambda^{\prime}_{1}=-1/\lambda_{1}italic_λ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = - 1 / italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and λ0=λ0/λ1subscriptsuperscript𝜆0subscript𝜆0subscript𝜆1\lambda^{\prime}_{0}=-\lambda_{0}/\lambda_{1}italic_λ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = - italic_λ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT / italic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, where the sign is just a convention, obtaining

δδπ(λ1H(π)+λ0Ωπ(x)𝑑x+ΩU(x)π(x)𝑑x)=0𝛿𝛿𝜋subscriptsuperscript𝜆1𝐻𝜋subscriptsuperscript𝜆0subscriptΩ𝜋𝑥differential-d𝑥subscriptΩ𝑈𝑥𝜋𝑥differential-d𝑥0\frac{\delta}{\delta\pi}\left(\lambda^{\prime}_{1}H(\pi)+\lambda^{\prime}_{0}% \int_{\Omega}\pi(x)dx+\int_{\Omega}U(x)\pi(x)dx\right)=0divide start_ARG italic_δ end_ARG start_ARG italic_δ italic_π end_ARG ( italic_λ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT italic_H ( italic_π ) + italic_λ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_π ( italic_x ) italic_d italic_x + ∫ start_POSTSUBSCRIPT roman_Ω end_POSTSUBSCRIPT italic_U ( italic_x ) italic_π ( italic_x ) italic_d italic_x ) = 0 (5.11)

While for the Helmholtz Free Energy, we have just to impose the thermodynamics constraint[fermi2012thermodynamics] F/S=T𝐹𝑆𝑇\partial F/\partial S=-T∂ italic_F / ∂ italic_S = - italic_T, that is λ1=1/Tsubscript𝜆11𝑇\lambda_{1}=-1/Titalic_λ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = - 1 / italic_T. ∎

Remark 5.1 (Free Energy in EBM training).

In Section 2.1 we presented the training procedure for an EBM as the KL divergence minimization. If ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is in the same class of ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, the global minimum in probability space corresponds to ρθ=ρsubscript𝜌𝜃subscript𝜌\rho_{\theta}=\rho_{*}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT, i.e. KL divergence equal to zero since by definition DKL(ρθρθ)=0subscript𝐷KLconditionalsubscript𝜌𝜃subscript𝜌𝜃0D_{\text{KL}}(\rho_{\theta}\parallel\rho_{\theta})=0italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) = 0. However, if we expand the such identity, we have

logZθ+βdUθ(x)ρθ(x)𝑑xH(ρθ)=0subscript𝑍𝜃𝛽subscriptsuperscript𝑑subscript𝑈𝜃𝑥subscript𝜌𝜃𝑥differential-d𝑥𝐻subscript𝜌𝜃0\log Z_{\theta}+\beta\int_{\mathbb{R}^{d}}U_{\theta}(x)\rho_{\theta}(x)dx-H(% \rho_{\theta})=0roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT + italic_β ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x - italic_H ( italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) = 0 (5.12)

where we used (2.10), and restored β𝛽\betaitalic_β in front of Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT (n.b. we put kB=1subscript𝑘𝐵1k_{B}=1italic_k start_POSTSUBSCRIPT italic_B end_POSTSUBSCRIPT = 1 and T=1𝑇1T=1italic_T = 1 in Section 2.1). If we identify Fθ=logZθsubscript𝐹𝜃subscript𝑍𝜃F_{\theta}=-\log Z_{\theta}italic_F start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = - roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT, we immediately notice that (5.12) is the definition of Helmholtz Free Energy. In fact, the convergence of the training corresponds to have reached the equilibrium. The equality F=U¯TH(π)𝐹¯𝑈𝑇𝐻𝜋F=\bar{U}-TH(\pi)italic_F = over¯ start_ARG italic_U end_ARG - italic_T italic_H ( italic_π ) is not true out of equilibrium — the KL divergence DKL(ρθρ)subscript𝐷KLconditionalsubscript𝜌𝜃subscript𝜌D_{\text{KL}}(\rho_{\theta}\parallel\rho_{*})italic_D start_POSTSUBSCRIPT KL end_POSTSUBSCRIPT ( italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ∥ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) is zero iff ρθ=ρsubscript𝜌𝜃subscript𝜌\rho_{\theta}=\rho_{*}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT. Moreover, it is even more clear the statement of Lemma 5.1: since

logZθ+minπ𝒫(Ω)I0[π]=1,ρθ>0[βdUθ(x)pi(x)𝑑xH(π)]=0subscript𝑍𝜃subscript𝜋𝒫Ωformulae-sequencesubscript𝐼0delimited-[]𝜋1subscript𝜌𝜃0𝛽subscriptsuperscript𝑑subscript𝑈𝜃𝑥𝑝𝑖𝑥differential-d𝑥𝐻𝜋0\log Z_{\theta}+\min_{\begin{subarray}{c}\pi\in\mathcal{P}(\Omega)\\ I_{0}[\pi]=1,\;\rho_{\theta}>0\end{subarray}}[\beta\int_{\mathbb{R}^{d}}U_{% \theta}(x)\\ pi(x)dx-H(\pi)]=0roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT + roman_min start_POSTSUBSCRIPT start_ARG start_ROW start_CELL italic_π ∈ caligraphic_P ( roman_Ω ) end_CELL end_ROW start_ROW start_CELL italic_I start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT [ italic_π ] = 1 , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT > 0 end_CELL end_ROW end_ARG end_POSTSUBSCRIPT [ italic_β ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_p italic_i ( italic_x ) italic_d italic_x - italic_H ( italic_π ) ] = 0 (5.13)

and F=U¯TH(π)𝐹¯𝑈𝑇𝐻𝜋F=\bar{U}-TH(\pi)italic_F = over¯ start_ARG italic_U end_ARG - italic_T italic_H ( italic_π ), at equilibrium F𝐹Fitalic_F is necessarily minimized in correspondence of F[ρθ]=logZθ𝐹delimited-[]subscript𝜌𝜃subscript𝑍𝜃F[\rho_{\theta}]=-\log Z_{\theta}italic_F [ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] = - roman_log italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT.

The requested compatibility between Thermodynamics and the Maximum Entropy principle in Lemma 5.1 represents the final ingredient needed to define the Boltzmann-Gibbs probability density associated with a system at equilibrium with a thermal reservoir at temperature T𝑇Titalic_T. For the purpose of this review, it would be beneficial to elaborate on the physical significance of EBM. Assuming we are dealing with an equilibrium ensemble, we presume that the parameters θ𝜃\thetaitalic_θ in the energy Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT have already been determined. Similar to a physical gas where particles move within an energy landscape, different datasets or even individual data points can be envisioned as snapshots of an evolving physical system. The crucial aspect is that from a statistical perspective, the average energy U¯¯𝑈\bar{U}over¯ start_ARG italic_U end_ARG associated with the EBM must remain constant, with fluctuations suppressed as the number of components increases. An example of dynamics consistent with such a constraint is Langevin dynamics. The connection with sampling and Physics becomes evident: sampling is the process of relaxation[evans2009dissipation] towards equilibrium. Utilizing our understanding of nature entails designing sampling routines capable of facilitating such relaxation.

We introduced the concept of free energy as a thermodynamic quantity minimized at equilibrium by the Boltzmann-Gibbs ensemble. Generally, computing free energy is a extensively studied problem in Chemistry[jorgensen1989free], spanning from organic Chemistry to protein folding[dinner2000understanding]. However, the concept of free energy appears ubiquitous, extending into seemingly disparate contexts far from computational chemistry, such as autoencoders[hinton1993autoencoders], lattice field theory[nicoli2021estimation], and neuroscience[friston2009free]. Invariably, it is associated with some equilibrium principle, often directly linked to the use of a generalization of the Boltzmann-Gibbs ensemble.

The importance of free energy can be readily understood: the expected value of any observable at equilibrium can be computed if we have access to the normalization constant of the Boltzmann-Gibbs ensemble, which is the partition function Z=eF𝑍superscript𝑒𝐹Z=e^{-F}italic_Z = italic_e start_POSTSUPERSCRIPT - italic_F end_POSTSUPERSCRIPT. However, as demonstrated in Section 2.1, computing the partition function, and consequently the free energy, is exceedingly complex using standard Monte Carlo methods for systems with many degrees of freedom, roughly corresponding to dimension d𝑑ditalic_d for EBM training. Among the various proposed advanced methods[stoltz2010free], the utilization of the Jarzynski identity[jarzynski1997nonequilibrium] stands out a very notable tool. Recently, an application of such result for improving the training of EBMs has been proposed, see [carbone2024efficient] for a detailed treatment.

6 State of the art: Contrastive Divergence and beyond

In this section we summarize the most common algorithm used for EBM training, namely Contrastive Divergence. For readers convenience, we fix the notation: in the following, ρθ(x)=ρθ(t)(x)=exp(Uθ(t)(x))/Zθsubscript𝜌𝜃𝑥subscript𝜌𝜃𝑡𝑥subscript𝑈𝜃𝑡𝑥subscript𝑍𝜃\rho_{\theta}(x)=\rho_{\theta(t)}(x)=\exp(-U_{\theta(t)}(x))/Z_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) = italic_ρ start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) = roman_exp ( - italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) ) / italic_Z start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT is the EBM we aim to train. As we showed in Section 2, training an EBM reduces to perform gradient-based optimization on cross-entropy. After some manipulation, the gradient of H(ρ,ρθ)𝐻subscript𝜌subscript𝜌𝜃H(\rho_{*},\rho_{\theta})italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) reduces to

θH(ρ,ρθ)=𝔼[θUθ]𝔼θ[θUθ]𝒟.subscript𝜃𝐻subscript𝜌subscript𝜌𝜃subscript𝔼delimited-[]subscript𝜃subscript𝑈𝜃subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃𝒟\displaystyle\partial_{\theta}H(\rho_{*},\rho_{\theta})=\mathbb{E}_{*}[% \partial_{\theta}U_{\theta}]-\mathbb{E}_{\theta}[\partial_{\theta}U_{\theta}]% \coloneqq-\mathcal{D}.∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_H ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ) = blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] - blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] ≔ - caligraphic_D . (6.1)

As we stressed in Remark 2.2, the main issue is the estimation of 𝔼θ[θUθ]subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃\mathbb{E}_{\theta}[\partial_{\theta}U_{\theta}]blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ]. An analytical computation is outreach for a generic Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT, as well as the use of numerical spline methods which are impractical in high dimension. The only possibility is to generate a set of N𝑁Nitalic_N samples {Xi}i=1Nsuperscriptsubscriptsuperscript𝑋𝑖𝑖1𝑁\{X^{i}\}_{i=1}^{N}{ italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT distributed as ρθ(t)subscript𝜌𝜃𝑡\rho_{\theta(t)}italic_ρ start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT and exploit a Monte Carlo integration, namely

𝔼θ[θUθ]1Ni=1NθUθ(Xi)Xiρθformulae-sequencesubscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃1𝑁superscriptsubscript𝑖1𝑁subscript𝜃subscript𝑈𝜃superscript𝑋𝑖similar-tosuperscript𝑋𝑖subscript𝜌𝜃\mathbb{E}_{\theta}[\partial_{\theta}U_{\theta}]\approx\frac{1}{N}\sum_{i=1}^{% N}\partial_{\theta}U_{\theta}(X^{i})\quad\quad X^{i}\sim\rho_{\theta}blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] ≈ divide start_ARG 1 end_ARG start_ARG italic_N end_ARG ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT ) italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT ∼ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT (6.2)

We stress that such generation is required at each optimization step of θ𝜃\thetaitalic_θ. The basic idea is to couple a gradient-based routine with a Markov Chain [liu2001monte] devoted to the generation of the needed samples (see Section 4 for a detailed description of sampling). Without loss of generality, we present the state-of-the-art algorithm using Unadjusted Langevin algorithm (ULA) [parisi1981correlation] as the sampler.

As mentioned, a problem encountered by standard sampling routines (such as ULA) is related to multimodality; that is, for fixed θ𝜃\thetaitalic_θ and a general initial condition X¯π¯similar-to¯𝑋¯𝜋\bar{X}\sim\bar{\pi}over¯ start_ARG italic_X end_ARG ∼ over¯ start_ARG italic_π end_ARG for the Markov Chain, there are no general results on the convergence rate towards the desired equilibrium Xρθsimilar-to𝑋subscript𝜌𝜃X\sim\rho_{\theta}italic_X ∼ italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT. However, if one were to choose a smart initial condition, such an issue is alleviated. For instance, in the ideal case where we could sample from an initial distribution ρ¯¯𝜌\bar{\rho}over¯ start_ARG italic_ρ end_ARG very close to ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT. In this sense, the naive approach in which the sampling routine restarts from the same "simple" distribution, like a Gaussian, for every optimization step, is not well adapted to EBM training. The question then arises: how to select an appropriate initial condition?

The idea of Contrastive Divergence[hinton2002training] (CD) and Persistent Contrastive Divergence[tieleman2008training] (PCD) in their original formulation is to use the unknown data distribution ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT as the initial condition for Markov Chain sampler. This is feasible since we have the dataset; that is, we could simply extract some data points from it and use them as the initial condition of the sampler at every optimization step. To better analyze the two routines, we present CD and PCD in Algorithms 1 and 2, where ULA is chosen as the sampling routine.

Algorithm 1 Contrastive divergence (CD) algorithm
1:Inputs: data points 𝒳={xi}i=1n𝒳superscriptsubscriptsuperscriptsubscript𝑥𝑖𝑖1𝑛\mathcal{X}=\{x_{*}^{i}\}_{i=1}^{n}caligraphic_X = { italic_x start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT in dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT; energy model Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT; optimizer step opt(θ,𝒟)opt𝜃𝒟\text{opt}(\theta,\mathcal{D})opt ( italic_θ , caligraphic_D ) using θ𝜃\thetaitalic_θ and the empirical gradient 𝒟𝒟\mathcal{D}caligraphic_D; initial parameters θ0subscript𝜃0\theta_{0}italic_θ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT; number of walkers N0𝑁subscript0N\in\mathbb{N}_{0}italic_N ∈ blackboard_N start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT with N<n𝑁𝑛N<nitalic_N < italic_n; total duration K𝐾K\in\mathbb{N}italic_K ∈ blackboard_N; ULA time step hhitalic_h; P𝑃P\in\mathbb{N}italic_P ∈ blackboard_N.
2:for k=1,,K1𝑘1𝐾1k=1,\ldots,K-1italic_k = 1 , … , italic_K - 1 do
3:     for i=1,,N𝑖1𝑁i=1,...,Nitalic_i = 1 , … , italic_N do
4:         X0i=RandomSample(𝒳)subscriptsuperscript𝑋𝑖0𝑅𝑎𝑛𝑑𝑜𝑚𝑆𝑎𝑚𝑝𝑙𝑒𝒳X^{i}_{0}=RandomSample(\mathcal{X})italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = italic_R italic_a italic_n italic_d italic_o italic_m italic_S italic_a italic_m italic_p italic_l italic_e ( caligraphic_X )
5:         for p=0,,P1𝑝0𝑃1p=0,...,P-1italic_p = 0 , … , italic_P - 1 do
6:              Xp+1i=XpihUθk(Xpi)+2hξpi,ξpi𝒩(0d,Id)formulae-sequencesubscriptsuperscript𝑋𝑖𝑝1superscriptsubscript𝑋𝑝𝑖subscript𝑈subscript𝜃𝑘subscriptsuperscript𝑋𝑖𝑝2subscriptsuperscript𝜉𝑖𝑝similar-tosubscriptsuperscript𝜉𝑖𝑝𝒩subscript0𝑑subscript𝐼𝑑X^{i}_{p+1}=X_{p}^{i}-h\nabla U_{\theta_{k}}(X^{i}_{p})+\sqrt{2h}\,\xi^{i}_{p}% ,\quad\quad\xi^{i}_{p}\sim\mathcal{N}(0_{d},I_{d})italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_p + 1 end_POSTSUBSCRIPT = italic_X start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT - italic_h ∇ italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT ) + square-root start_ARG 2 italic_h end_ARG italic_ξ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT , italic_ξ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT ∼ caligraphic_N ( 0 start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT , italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT ) \triangleright ULA
7:         end for
8:     end for
9:     𝒟~k=N1i=1NθUθk(XPi)n1i=1nθUθk(xi)subscript~𝒟𝑘superscript𝑁1superscriptsubscript𝑖1𝑁subscript𝜃subscript𝑈subscript𝜃𝑘superscriptsubscript𝑋𝑃𝑖superscript𝑛1superscriptsubscript𝑖1𝑛subscript𝜃subscript𝑈subscript𝜃𝑘subscriptsuperscript𝑥𝑖\tilde{\mathcal{D}}_{k}=N^{-1}\sum_{i=1}^{N}\partial_{\theta}U_{\theta_{k}}(X_% {P}^{i})-n^{-1}\sum_{i=1}^{n}\partial_{\theta}U_{\theta_{k}}(x^{i}_{*})over~ start_ARG caligraphic_D end_ARG start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT = italic_N start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_X start_POSTSUBSCRIPT italic_P end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT ) - italic_n start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT )\triangleright empirical gradient
10:     θk+1=opt(θk,𝒟~k)subscript𝜃𝑘1optsubscript𝜃𝑘subscript~𝒟𝑘\theta_{k+1}=\text{opt}(\theta_{k},\tilde{\mathcal{D}}_{k})italic_θ start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = opt ( italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , over~ start_ARG caligraphic_D end_ARG start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT )\triangleright optimization step
11:end for
12:Outputs: Optimized energy UθKsubscript𝑈subscript𝜃𝐾U_{\theta_{K}}italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_K end_POSTSUBSCRIPT end_POSTSUBSCRIPT; set of walkers {XPi}i=1Nsuperscriptsubscriptsuperscriptsubscript𝑋𝑃𝑖𝑖1𝑁\{X_{P}^{i}\}_{i=1}^{N}{ italic_X start_POSTSUBSCRIPT italic_P end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT
Algorithm 2 Persistent contrastive divergence (PCD) algorithm
1:Inputs: data points 𝒳={xi}i=1n𝒳superscriptsubscriptsubscriptsuperscript𝑥𝑖𝑖1𝑛\mathcal{X}=\{x^{*}_{i}\}_{i=1}^{n}caligraphic_X = { italic_x start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT in dsuperscript𝑑\mathbb{R}^{d}blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT; energy model Uθsubscript𝑈𝜃U_{\theta}italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT; optimizer step opt(θ,𝒟)opt𝜃𝒟\text{opt}(\theta,\mathcal{D})opt ( italic_θ , caligraphic_D ) using θ𝜃\thetaitalic_θ and the empirical CE gradient 𝒟𝒟\mathcal{D}caligraphic_D; initial parameters θ0subscript𝜃0\theta_{0}italic_θ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT; number of walkers N0𝑁subscript0N\in\mathbb{N}_{0}italic_N ∈ blackboard_N start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT with N<n𝑁𝑛N<nitalic_N < italic_n; total duration K𝐾K\in\mathbb{N}italic_K ∈ blackboard_N; ULA time step hhitalic_h.
2:X0i=RandomSample(𝒳)superscriptsubscript𝑋0𝑖𝑅𝑎𝑛𝑑𝑜𝑚𝑆𝑎𝑚𝑝𝑙𝑒𝒳X_{0}^{i}=RandomSample(\mathcal{X})italic_X start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT = italic_R italic_a italic_n italic_d italic_o italic_m italic_S italic_a italic_m italic_p italic_l italic_e ( caligraphic_X ) for i=1,,N𝑖1𝑁i=1,\ldots,Nitalic_i = 1 , … , italic_N.
3:for k=1,,K1𝑘1𝐾1k=1,\ldots,K-1italic_k = 1 , … , italic_K - 1 do
4:     𝒟~k=N1i=1NθUθk(Xki)n1i=1nθUθk(xi)subscript~𝒟𝑘superscript𝑁1superscriptsubscript𝑖1𝑁subscript𝜃subscript𝑈subscript𝜃𝑘superscriptsubscript𝑋𝑘𝑖superscript𝑛1superscriptsubscript𝑖1𝑛subscript𝜃subscript𝑈subscript𝜃𝑘subscriptsuperscript𝑥𝑖\tilde{\mathcal{D}}_{k}=N^{-1}\sum_{i=1}^{N}\partial_{\theta}U_{\theta_{k}}(X_% {k}^{i})-n^{-1}\sum_{i=1}^{n}\partial_{\theta}U_{\theta_{k}}(x^{i}_{*})over~ start_ARG caligraphic_D end_ARG start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT = italic_N start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT ) - italic_n start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ∑ start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT )\triangleright empirical gradient
5:     θk+1=opt(θk,𝒟~k)subscript𝜃𝑘1optsubscript𝜃𝑘subscript~𝒟𝑘\theta_{k+1}=\text{opt}(\theta_{k},\tilde{\mathcal{D}}_{k})italic_θ start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = opt ( italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , over~ start_ARG caligraphic_D end_ARG start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT )\triangleright optimization step
6:     for i=1,,N𝑖1𝑁i=1,...,Nitalic_i = 1 , … , italic_N do
7:         Xk+1i=XkihUθk(Xki)+2hξki,ξki𝒩(0d,Id)formulae-sequencesubscriptsuperscript𝑋𝑖𝑘1superscriptsubscript𝑋𝑘𝑖subscript𝑈subscript𝜃𝑘subscriptsuperscript𝑋𝑖𝑘2subscriptsuperscript𝜉𝑖𝑘similar-tosubscriptsuperscript𝜉𝑖𝑘𝒩subscript0𝑑subscript𝐼𝑑X^{i}_{k+1}=X_{k}^{i}-h\nabla U_{\theta_{k}}(X^{i}_{k})+\sqrt{2h}\,\xi^{i}_{k}% ,\quad\quad\xi^{i}_{k}\sim\mathcal{N}(0_{d},I_{d})italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k + 1 end_POSTSUBSCRIPT = italic_X start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT - italic_h ∇ italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT ( italic_X start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ) + square-root start_ARG 2 italic_h end_ARG italic_ξ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT , italic_ξ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ∼ caligraphic_N ( 0 start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT , italic_I start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT ) \triangleright ULA
8:     end for
9:end for
10:Outputs: Optimized energy UθKsubscript𝑈subscript𝜃𝐾U_{\theta_{K}}italic_U start_POSTSUBSCRIPT italic_θ start_POSTSUBSCRIPT italic_K end_POSTSUBSCRIPT end_POSTSUBSCRIPT; set of walkers {XKi}i=1Nsuperscriptsubscriptsuperscriptsubscript𝑋𝐾𝑖𝑖1𝑁\{X_{K}^{i}\}_{i=1}^{N}{ italic_X start_POSTSUBSCRIPT italic_K end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT } start_POSTSUBSCRIPT italic_i = 1 end_POSTSUBSCRIPT start_POSTSUPERSCRIPT italic_N end_POSTSUPERSCRIPT.

Let us clarify the notation. Each X𝑋Xitalic_X used for the estimation of the gradient of cross-entropy is named a "walker". Each walker is indexed by a superscript, and the function RandomSample(𝒳)𝑅𝑎𝑛𝑑𝑜𝑚𝑆𝑎𝑚𝑝𝑙𝑒𝒳RandomSample(\mathcal{X})italic_R italic_a italic_n italic_d italic_o italic_m italic_S italic_a italic_m italic_p italic_l italic_e ( caligraphic_X ) performs a random extraction of N𝑁Nitalic_N points from 𝒳𝒳\mathcal{X}caligraphic_X. In CD, the chain for sampling is reinitialized at data at every cycle; in PCD, as for the name, the chain is "persistent", meaning it starts from the data just at the first iteration — after each optimization step, the sampling routine restarts from the samples found at the previous iteration. Traditionally, xsuperscript𝑥x^{*}italic_x start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT is referred to as "positive" samples, while the samples from ρθsubscript𝜌𝜃\rho_{\theta}italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT are termed "negative", especially in the community of Boltzmann Machines. The adjective "Contrastive" originates from the minus sign between expectations in (6.1): the contribution of negative and positive samples to the variation of cross-entropy is indeed opposite. In fact, the ODE associated to gradient descent on cross-entropy minimization is

θ˙=𝔼θ[θUθ]𝔼[θUθ]˙𝜃subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃subscript𝔼delimited-[]subscript𝜃subscript𝑈𝜃\dot{\theta}=\mathbb{E}_{\theta}[\partial_{\theta}U_{\theta}]-\mathbb{E}_{*}[% \partial_{\theta}U_{\theta}]over˙ start_ARG italic_θ end_ARG = blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] - blackboard_E start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] (6.3)

This equation can be interpreted as gradient descent on the energy per positive sample and gradient ascent for the energy per negative sample. It corresponds to increasing the probability of data points in the dataset and decreasing it for the samples obtained from the chain. Stationarity is reached when ρ=ρθsubscript𝜌subscript𝜌𝜃\rho_{*}=\rho_{\theta}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT, so that generated points belong to the same distribution as true data points.

The natural question that arises concerns the convergence of the algorithms. To simplify the treatment, we do not analyze the algorithms for a finite set of walkers, but we study the time evolution of the probability distribution of the walkers ρˇ(t,x)ˇ𝜌𝑡𝑥\check{\rho}(t,x)overroman_ˇ start_ARG italic_ρ end_ARG ( italic_t , italic_x ). Ideally, this should remove any possible spurious bias from the analysis and permit an easier analytical study. We can write down an equation that mimics the evolution of the PDF of the walkers in the CD algorithm in the continuous-time limit. This equation reads:

tρˇ=α(Uθ(t)(x)ρˇ+ρˇ)ν(ρˇρ),ρˇ(t=0)=ρformulae-sequencesubscript𝑡ˇ𝜌𝛼subscript𝑈𝜃𝑡𝑥ˇ𝜌ˇ𝜌𝜈ˇ𝜌subscript𝜌ˇ𝜌𝑡0subscript𝜌\partial_{t}\check{\rho}=\alpha\nabla\cdot\left(\nabla U_{\theta(t)}(x)\check{% \rho}+\nabla\check{\rho}\right)-\nu(\check{\rho}-\rho_{*}),\qquad\check{\rho}(% t=0)=\rho_{*}∂ start_POSTSUBSCRIPT italic_t end_POSTSUBSCRIPT overroman_ˇ start_ARG italic_ρ end_ARG = italic_α ∇ ⋅ ( ∇ italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) overroman_ˇ start_ARG italic_ρ end_ARG + ∇ overroman_ˇ start_ARG italic_ρ end_ARG ) - italic_ν ( overroman_ˇ start_ARG italic_ρ end_ARG - italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ) , overroman_ˇ start_ARG italic_ρ end_ARG ( italic_t = 0 ) = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT (6.4)

with fixed α>0𝛼0\alpha>0italic_α > 0 and where the parameter ν>0𝜈0\nu>0italic_ν > 0 controls the rate at which the walkers are reinitialized at the data points: the last term in (6.4) is a birth-death term that captures the effect of these reinitializations. The solution to this equation is not available in closed from (and ρˇ(t,x)ρθ(t)(x)ˇ𝜌𝑡𝑥subscript𝜌𝜃𝑡𝑥\check{\rho}(t,x)\not=\rho_{\theta(t)}(x)overroman_ˇ start_ARG italic_ρ end_ARG ( italic_t , italic_x ) ≠ italic_ρ start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) in general), but in the limit of large ν𝜈\nuitalic_ν (i.e. with very frequent reinitializations), we can show[domingoenrich2022dual] that

ρˇ(t,x)=ρ(x)+ν1α(Uθ(t)(x)ρ(x)+ρ(x))+O(ν2).ˇ𝜌𝑡𝑥subscript𝜌𝑥superscript𝜈1𝛼subscript𝑈𝜃𝑡𝑥subscript𝜌𝑥subscript𝜌𝑥𝑂superscript𝜈2\check{\rho}(t,x)=\rho_{*}(x)+\nu^{-1}\alpha\nabla\cdot\left(\nabla U_{\theta(% t)}(x)\rho_{*}(x)+\nabla\rho_{*}(x)\right)+O(\nu^{-2}).overroman_ˇ start_ARG italic_ρ end_ARG ( italic_t , italic_x ) = italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) + italic_ν start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT italic_α ∇ ⋅ ( ∇ italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) + ∇ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) ) + italic_O ( italic_ν start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT ) . (6.5)

As a result, the gradient of cross-entropy (6.1) is

dθUθ(t)(x)(ρ(x)ρˇ(t,x))dxsubscriptsuperscript𝑑subscript𝜃subscript𝑈𝜃𝑡𝑥subscript𝜌𝑥ˇ𝜌𝑡𝑥𝑑𝑥\displaystyle\int_{\mathbb{R}^{d}}\partial_{\theta}U_{\theta(t)}(x)(\rho_{*}(x% )-\check{\rho}(t,x))dx∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) ( italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) - overroman_ˇ start_ARG italic_ρ end_ARG ( italic_t , italic_x ) ) italic_d italic_x (6.6)
=ν1dθUθ(t)(x)(Uθ(t)(x)ρ(x)+ρ(x))dx+O(ν2)absentsuperscript𝜈1subscriptsuperscript𝑑subscript𝜃subscript𝑈𝜃𝑡𝑥subscript𝑈𝜃𝑡𝑥subscript𝜌𝑥subscript𝜌𝑥𝑑𝑥𝑂superscript𝜈2\displaystyle=-\nu^{-1}\int_{\mathbb{R}^{d}}\partial_{\theta}U_{\theta(t)}(x)% \nabla\cdot\left(U_{\theta(t)}(x)\rho_{*}(x)+\nabla\rho_{*}(x)\right)dx+O(\nu^% {-2})= - italic_ν start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) ∇ ⋅ ( italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) + ∇ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) ) italic_d italic_x + italic_O ( italic_ν start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT )
=ν1d(θUθ(t)(x)Uθ(t)(x)θΔUθ(t)(x))ρ(x)𝑑x+O(ν2)absentsuperscript𝜈1subscriptsuperscript𝑑subscript𝜃subscript𝑈𝜃𝑡𝑥subscript𝑈𝜃𝑡𝑥subscript𝜃Δsubscript𝑈𝜃𝑡𝑥subscript𝜌𝑥differential-d𝑥𝑂superscript𝜈2\displaystyle=\nu^{-1}\int_{\mathbb{R}^{d}}\left(\partial_{\theta}\nabla U_{% \theta(t)}(x)\cdot\nabla U_{\theta(t)}(x)-\partial_{\theta}\Delta U_{\theta(t)% }(x)\right)\rho_{*}(x)dx+O(\nu^{-2})= italic_ν start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ( ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ∇ italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) ⋅ ∇ italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) - ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT roman_Δ italic_U start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x + italic_O ( italic_ν start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT )

The leading order term at the right hand side is precisely ν1superscript𝜈1\nu^{-1}italic_ν start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT times the gradient with respect to θ𝜃\thetaitalic_θ of the Fisher divergence

12d|Uθ(x)+logρ(x)|2ρ(x)𝑑x12subscriptsuperscript𝑑superscriptsubscript𝑈𝜃𝑥subscript𝜌𝑥2subscript𝜌𝑥differential-d𝑥\displaystyle\frac{1}{2}\int_{\mathbb{R}^{d}}|\nabla U_{\theta}(x)+\nabla\log% \rho_{*}(x)|^{2}\rho_{*}(x)dxdivide start_ARG 1 end_ARG start_ARG 2 end_ARG ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT | ∇ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) + ∇ roman_log italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x (6.7)
=12d[|Uθ(x)|22ΔUθ(x)+|logρ(x)|2]ρ(x)𝑑xabsent12subscriptsuperscript𝑑delimited-[]superscriptsubscript𝑈𝜃𝑥22Δsubscript𝑈𝜃𝑥superscriptsubscript𝜌𝑥2subscript𝜌𝑥differential-d𝑥\displaystyle=\frac{1}{2}\int_{\mathbb{R}^{d}}\left[|\nabla U_{\theta}(x)|^{2}% -2\Delta U_{\theta}(x)+|\nabla\log\rho_{*}(x)|^{2}\right]\rho_{*}(x)dx= divide start_ARG 1 end_ARG start_ARG 2 end_ARG ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT [ | ∇ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT - 2 roman_Δ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) + | ∇ roman_log italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) | start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ] italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x

where ΔΔ\Deltaroman_Δ denotes the Laplacian and we used

dUθ(x)logρ(x)ρ(x)𝑑x=dUθ(x)ρ(x)𝑑x=dΔUθ(x)ρ(x)𝑑xsubscriptsuperscript𝑑subscript𝑈𝜃𝑥subscript𝜌𝑥subscript𝜌𝑥differential-d𝑥subscriptsuperscript𝑑subscript𝑈𝜃𝑥subscript𝜌𝑥differential-d𝑥subscriptsuperscript𝑑Δsubscript𝑈𝜃𝑥subscript𝜌𝑥differential-d𝑥\int_{\mathbb{R}^{d}}\nabla U_{\theta}(x)\cdot\nabla\log\rho_{*}(x)\rho_{*}(x)% dx=\int_{\mathbb{R}^{d}}\nabla U_{\theta}(x)\cdot\nabla\rho_{*}(x)dx=-\int_{% \mathbb{R}^{d}}\Delta U_{\theta}(x)\rho_{*}(x)dx∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∇ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ⋅ ∇ roman_log italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x = ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ∇ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) ⋅ ∇ italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x = - ∫ start_POSTSUBSCRIPT blackboard_R start_POSTSUPERSCRIPT italic_d end_POSTSUPERSCRIPT end_POSTSUBSCRIPT roman_Δ italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ( italic_x ) italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT ( italic_x ) italic_d italic_x (6.8)

This confirms the known fact that the CD algorithm effectively performs GD on the Fisher divergence rather than the cross-entropy[hyvarinen2007connections], similarly to score matching.
Regarding PCD, the associated PDE is (6.4) with ν=0𝜈0\nu=0italic_ν = 0. Again, the solution ρˇ(t,x)ρθ(t)(x)ˇ𝜌𝑡𝑥subscript𝜌𝜃𝑡𝑥\check{\rho}(t,x)\neq\rho_{\theta(t)}(x)overroman_ˇ start_ARG italic_ρ end_ARG ( italic_t , italic_x ) ≠ italic_ρ start_POSTSUBSCRIPT italic_θ ( italic_t ) end_POSTSUBSCRIPT ( italic_x ) in general, thus for any finite α𝛼\alphaitalic_α, we have 𝔼ρˇ[θUθ]𝔼θ[θUθ]subscript𝔼ˇ𝜌delimited-[]subscript𝜃subscript𝑈𝜃subscript𝔼𝜃delimited-[]subscript𝜃subscript𝑈𝜃\mathbb{E}_{\check{\rho}}[\partial_{\theta}U_{\theta}]\neq\mathbb{E}_{\theta}[% \partial_{\theta}U_{\theta}]blackboard_E start_POSTSUBSCRIPT overroman_ˇ start_ARG italic_ρ end_ARG end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ] ≠ blackboard_E start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT [ ∂ start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT italic_U start_POSTSUBSCRIPT italic_θ end_POSTSUBSCRIPT ]. In other words, one cannot be sure to perform true gradient descent on cross-entropy — if we were able to estimate the loss, we could observe non-monotonic behavior. Extensions of standard PCD exploit an initial condition different from ρsubscript𝜌\rho_{*}italic_ρ start_POSTSUBSCRIPT ∗ end_POSTSUBSCRIPT for the persistent chain, but such approach is plagued by the same issue regarding the convergence rate towards equilibrium.
The takeaway message is that from an analytical standpoint, neither CD nor PCD actually perform a gradient-based optimization of cross-entropy. One important issue is that the presence of bias is related to time scales, in PCD regarding the length of the Markov Chain for sampling, and in CD also for the reinitialization frequency. Even if they are widely adopted in practice, the presence of such criticality even in an ideal setup is far from optimal and critically links the applicability of EBMs to the particular situation under study.
The concluding key remark is the following: generating single samples is not problematic in the context of CD or PCD, but, because of the properties of Fisher divergence, the global mass distribution could happen to be incorrectly inferred, in particular in presence of well separated modes in the target probability ensemble. Alternative approaches for EBM training based on Jarzynski identity have been proposed in [carbone2024efficient], where a detailed comparison with CD and PCD and numerical experiments are widely discussed.

7 Conclusion

In conclusion, Energy-Based Models (EBMs) represent a versatile approach within the landscape of generative modeling, offering significant insights and applications, especially pertinent to the field of physics, and towards an interpretable generative artificial intelligence. This review has provided a detailed exploration of the fundamental principles and methodologies underlying EBMs, emphasizing their synergy with statistical mechanics. By elucidating the connections between EBMs and other generative models such as Generative Adversarial Networks (GANs), Variational Autoencoders (VAEs), and Normalizing Flows, we have highlighted the unique advantages and challenges associated with each framework. Then, the sampling techniques necessary for effective EBM implementation, including Markov Chain Monte Carlo (MCMC) methods, have been thoroughly examined. The parallels drawn between EBM concepts and statistical mechanics principles, particularly through the lens of energy functions and partition functions, underscore the natural alignment of EBMs with physical systems and processes.

Moreover, we have reviewed the state-of-the-art training methodologies for EBMs, as Constrastive Learning, also mentioning recent innovations that enhance model performance, stability, and efficiency. These advancements are crucial for addressing the inherent difficulties in training EBMs, such as energy function optimization and mode collapse. A significant focus of this review has been on bridging the gaps between the diverse communities that contribute to the development and application of generative models. The interdisciplinary nature of EBMs means that insights from physics, computer science, and machine learning are all essential for a comprehensive understanding and effective utilization of these models. By clarifying the complex interconnections between these fields, we aim to foster a more cohesive and collaborative approach to EBM research and application.

In summary, EBMs offer a robust framework for generative modeling, with implications for both theoretical research and practical applications. We hope this review serves as a valuable resource for physicists and other researchers, providing clarity and insight into the multifaceted world of Energy-Based Models and encouraging further exploration and collaboration across disciplines.

\printbibliography