Abstract
The method of choice for integrating the time-dependent Fokker–Planck equation (FPE) in high-dimension is to generate samples from the solution via integration of the associated stochastic differential equation (SDE). Here, we study an alternative scheme based on integrating an ordinary differential equation that describes the flow of probability. Acting as a transport map, this equation deterministically pushes samples from the initial density onto samples from the solution at any later time. Unlike integration of the stochastic dynamics, the method has the advantage of giving direct access to quantities that are challenging to estimate from trajectories alone, such as the probability current, the density itself, and its entropy. The probability flow equation depends on the gradient of the logarithm of the solution (its 'score'), and so is a-priori unknown. To resolve this dependence, we model the score with a deep neural network that is learned on-the-fly by propagating a set of samples according to the instantaneous probability current. We show theoretically that the proposed approach controls the Kullback–Leibler (KL) divergence from the learned solution to the target, while learning on external samples from the SDE does not control either direction of the KL divergence. Empirically, we consider several high-dimensional FPEs from the physics of interacting particle systems. We find that the method accurately matches analytical solutions when they are available as well as moments computed via Monte-Carlo when they are not. Moreover, the method offers compelling predictions for the global entropy production rate that out-perform those obtained from learning on stochastic trajectories, and can effectively capture non-equilibrium steady-state probability currents over long time intervals.
Export citation and abstract BibTeX RIS
1. Introduction
The time evolution of many dynamical processes occurring in the natural sciences, engineering, economics, and statistics are naturally described in the language of stochastic differential equations (SDE) [12, 14, 40]. Typically, one is interested in the probability density function (PDF) of these processes, which describes the probability that the system will occupy a given state at a given time. The density can be obtained as the solution to a Fokker–Planck equation (FPE), which can generically be written as [1, 45]
where denotes the value of the density at time t, is a vector field known as the drift, and is a positive-semidefinite tensor known as the diffusion matrix. (1) must be solved for from some initial condition , but in all but the simplest cases, the solution is not available analytically and can only be approximated via numerical integration.
High-dimensionality. For many systems of interest—such as interacting particle systems in statistical physics [4, 56], stochastic control systems [26], and models in mathematical finance [40]—the dimensionality d can be very large. This renders standard numerical methods for partial differential equations inapplicable, which become infeasible for d as small as five or six due to an exponential scaling of the computational complexity with d. The standard solution to this problem is a Monte-Carlo approach, whereby the SDE associated with (1)
is evolved via numerical integration to obtain a large number n of trajectories [24]. In (2), satisfies and Wt is a standard Brownian motion on . Assuming that we can draw samples from the initial PDF ρ0, simulation of (2) enables the estimation of expectations via empirical averages
where is an observable of interest. While widely used, this method only provides samples from , and hence other quantities of interest like the value of itself or the time-dependent differential entropy of the system require sophisticated interpolation methods that typically do not scale well to high-dimension.
A transport map approach. Another possibility, building on recent theoretical advances that connect transportation of measures to the FPE [22], is to recast (1) as the transport equation [49, 60]
where we have defined the velocity field
This formulation reveals that can be viewed as the pushforward of ρ0 under the flow map of the ordinary differential equation
Equation (6) is known as the probability flow equation, and its solution has the remarkable property that if x is a sample from ρ0, then will be a sample from . Viewing as a transport map and letting denote the push-forward operation, can be evaluated at any position in Ω via the change of variables formula [49, 60]
where is obtained by solving (6) backward from some given x. Importantly, access to the PDF as provided by (7) immediately gives the ability to compute quantities such as the probability current or the entropy; by contrast, this capability is absent when directly simulating the SDE.
Learning the flow. The simplicity of the probability flow equation (6) is somewhat deceptive, because the velocity depends explicitly on the solution to the FPE (1). Nevertheless, recent work in generative modeling via score-based diffusion [52–54] has shown that it is possible to use deep neural networks to estimate , or equivalently the so-called score of the solution density. Here, we introduce a variant of score-based diffusion modeling in which the score is learned on-the-fly over samples generated by the probability flow equation itself. The method is self-contained and enables us to bypass simulation of the SDE entirely; moreover, we provide both empirical and theoretical evidence that the resulting self-consistent training procedure offers improved performance when compared to training via samples produced from simulation of the SDE.
1.1. Contributions
Our contributions are both theoretical and computational:
- We provide a bound on the Kullback–Leibler (KL) divergence from the estimate ρt produced via an approximate velocity field vt to the target . This bound motivates our approach, and shows that minimizing the discrepancy between the learned score and the score of the push-forward distribution systematically improves the accuracy of ρt .
- Based on this bound, we introduce two optimization problems that can be used to learn the velocity field (5) in the transport equation (4) so that its solution coincides with that of the FPE (1). Due to its similarities with score-based diffusion approaches in generative modeling (SBDM), we call the resulting method score-based transport modeling (SBTM).
- We provide specific estimators for quantities that can be computed via SBTM but are not directly available from samples alone, like point-wise evaluation of ρt itself, the differential entropy, and the probability current.
- We test SBTM on several examples involving interacting particles that pairwise repel but are kept close by common attraction to a moving trap. In these systems, the FPE is high-dimensional due to the large number of particles, which vary from 5 to 50 in the examples below. Problems of this type frequently appear in the molecular dynamics of externally-driven soft matter systems [13, 56]. We show that our method can be used to accurately compute the entropy production rate, a quantity of interest in the active matter community [39], as it quantifies the out-of-equilibrium nature of the system's dynamics.
1.2. Notation and assumptions
Throughout, we assume that the stochastic process (2) evolves over , though our results can easily be extended to domains with either reflecting [30] or periodic boundary conditions. We let denote the Euclidean norm on vectors and denote the Fröbenius norm on matrices. For our theory, we assume that the drift vector and the diffusion tensor with are both twice-differentiable in x for each t and satisfy, for some fixed C > 0, L > 0, and T > 0
so that the solution to the SDE (2) is well-defined for [40]. We further assume that the initial PDF ρ0 is three-times differentiable, positive everywhere on Ω, and such that ; then enjoys the same properties at all times . Finally, we assume that is K-smooth globally for , i.e.
This technical assumption is needed to guarantee global existence and uniqueness of the solution of the probability flow equation. Throughout, we use the shorthand notation interchangeably for a time-dependent quantity yt .
2. Related work
Score matching. Our approach builds directly on the toolbox of score matching originally developed by Hyvärinen [17–20] and more recently extended in the context of diffusion-based generative modeling [7, 10, 38, 52, 53, 55]. These approaches assume access to training samples from the target distribution (e.g. in the form of examples of natural images). Here, we bypass this need and use the probability flow equation to obtain the samples needed to learn an approximation of the score. Lu et al [34] recently showed that using the transport equation (10) with a velocity field learned via SBDM can lead to inaccuracies in the likelihood unless higher-order score terms are well-approximated. Proposition 1 shows that the self-consistent approach used in SBTM solves these issues and ensures a systematic approximation of the target . Lai et al [27] recently used a similar idea to improve sample quality with score-based probability flow equations in generative modeling.
Density estimation and Bayesian inference. Our method shares commonalities with transport map-based approaches [37] for density estimation and variational inference [2, 62] such as normalizing flows [16, 25, 41, 44, 57, 58]. Moreover, because expectations are approximated over a set of samples according to (3), the method also inherits elements of classical 'particle-based' approaches for density estimation such as Markov chain Monte Carlo [46] and sequential Monte Carlo [6, 9].
Our approach is also reminiscent of a recent line of work in Bayesian inference that aims to combine the strengths of particle methods with those of variational approximations [5, 48]. In particular, the method we propose bears some similarity with Stein variational gradient descent (SVGD) [31–33] (see also [28, 35]), in that both methods approximate the target distribution via deterministic propagation of a set of samples. The key differences are that (i) our method learns the map used to propagate the samples, while the map in SVGD corresponds to optimization of the kernelized Stein discrepancy, and (ii) the methods have distinct goals, as we are interested in capturing the dynamical evolution of rather than sampling from an equilibrium density. Indeed, many of the examples we consider do not have an equilibrium density, i.e. does not exist.
Approaches for solving the FPE. Most closely connected to our paper are the works by Maoutsa et al [36] and Shen et al [50], who similarly propose to bypass the SDE through use of the probability flow equation, building on earlier work by Degond and Mustieles [8] and Russo [47]. The critical differences between Maoutsa et al [36] and our approach are that they perform estimation over a linear space or a reproducing kernel Hilbert space rather than over the significantly richer class of neural networks, and that they train using the original score matching loss of Hyvärinen [18], while the use of neural networks requires the introduction of regularized variants. Because of this, [36] studies systems of dimension less than or equal to five; in contrast, we study systems with dimensionality as high as 100.
Concurrently to our work, Shen et al [50] proposed a variational problem similar to SBTM. A key difference is that SBTM is not limited to FPEs that can be viewed as a gradient flow in the Wasserstein metric over some energy (i.e. the drift term in the SDE (2) need not be the gradient of a potential), and that it allows for spatially-dependent and rank-deficient diffusion matrices. Moreover, our theoretical results are similar, but by avoiding the use of costly Sobolev norms lead to a practical optimization problem that we show can be solved in high dimension and over long times. In a follow-up to Shen et al [50] and our present work, Li et al [29] propose an algorithm that can be seen as an expectation-maximization algorithm for the loss function in (15), which avoids calculation of Gt according to equation (13).
Algorithm 1. Sequential score-based transport modeling. |
---|
1: Input: An initial time . A set of n samples from . A set of NT timesteps . |
2: Initialize sample locations for . |
3: for do |
4: Optimize: . |
5: Propagate samples: |
6: Set . |
7: Output: A set of n samples from and the score for all . |
Neural-network solutions to PDEs. Our approach can also be viewed as an alternative to recent neural network-based methods for the solution of partial differential equations (see e.g. [3, 11, 15, 42, 51]). Unlike these existing approaches, our method is tailored to the solution of the FPE and guarantees that the solution is a valid probability density. Our approach is fundamentally Lagrangian in nature, which has the advantage that it only involves learning quantities locally at the positions of a set of evolving samples; this is naturally conducive to efficient scaling for high-dimensional systems.
3. Methodology
3.1. Score-based transport modeling
Let denote an approximation to the score of the target , and consider the solution to the transport equation
subject to the initial condition . Our goal is to develop a variational principle that may be used to adjust st so that ρt tracks . Our approach is based on the following inequality, whose proof may be found in appendix B.1:
Proposition 1 (Control of the KL divergence). Assume that the conditions listed in section 1.2 hold. Let ρt denote the solution to the transport equation (10), and let denote the solution to the FPE (1). Assume that for all . Then
where .
In particular, (11) implies that for any we have explicit control on the KL divergence
Remarkably, (12) only depends on the approximate ρt and does not include : it states that the accuracy of ρt as an approximation of can be improved by enforcing agreement between st and . This means that we can optimize (12) without making use of external data from , which offers a self-consistent objective function to learn the score st using (10) alone.
The primary difficulty with this approach is that ρt
must be considered as a functional of st
, since the velocity vt
used in (10) depends on st
. To render the resulting minimization of the right-hand side of (12) practical, we can exploit that (10) can be solved via the method of characteristics, as summarized in appendix
Proposition 2 (Score-based transport modeling). Assume that the conditions listed in section 1.2 hold. Define and consider
Then solves (10), the equality holds, and for any
Moreover, if is a minimizer of the constrained optimization problem
then where solves the FPE (1). The map associated to any minimizer is a transport map from ρ0 to , i.e.
Proposition 2 is proven in appendix B.3. The result also holds with a standard Euclidean norm replacing the diffusion-weighted norm, in which case the minimizer is unique and is given by . In the special case when the SDE is an Ornstein–Uhlenbeck (OU) process, the score and the equations for both Xt
and Gt
can be written explicitly; they are studied in appendix
In practice, the objective in (15) can be estimated empirically by generating samples from ρ0 and solving the equations for and with . The constrained minimization problem (15) can then in principle be solved with gradient-based techniques via the adjoint method. The corresponding equations are written in appendix B.3, but they involve fourth-order spatial derivatives that are computationally expensive to compute via automatic differentiation. Moreover, each gradient step requires solving a system of ordinary differential equations whose dimensionality is equal to the number of samples used to compute expectations times the dimension of (1). Instead, we now develop a sequential timestepping procedure that avoids these difficulties entirely, and as a byproduct can scale to arbitrarily long time windows.
3.2. Sequential score-based transport modeling
An alternative to the constrained minimization in proposition 2 is to consider an approach whereby the score st is obtained independently at each time to ensure that remains small. This suggests choosing st to minimize , which admits a simple closed-form bound, as shown in proposition 1. While this explicit form can be used directly, an application of Stein's identity recovers an implicit objective analogous to Hyvärinen score-matching that is equivalent to minimizing but obviates the calculation of Gt . Expanding the square in (11) and applying , we may write
Because is independent of st , we may neglect the corresponding square term during optimization. This leads to a simple and comparatively less expensive way to build the pushforward such that sequentially in time, as stated in the following proposition.
Proposition 3 (Sequential SBTM). In the same setting as proposition 2, let solve the first equation in (13) with . Let st be obtained via
Then, each minimizer of (17) satisfies where is the solution to (1). Moreover, the map associated to is a transport map from ρ0 to .
Proposition 3 is proven in appendix B.4. Critically, (17) is no longer a constrained optimization problem. Given the current value of Xt at any time t, we can obtain st via direct minimization of the objective in (17). Given st , we may compute the right-hand side of (13) and propagate Xt (and possibly Gt ) forward in time. The resulting procedure, which alternates between self-consistent score estimation and sample propagation, is presented in algorithm 1 for the choice of a forward-Euler integration routine in time. The output of the method produces a feasible solution for (15) because satisfies the first constraint in (13) by construction. Moreover, because the method controls at each t, it also controls by integration; an a-posteriori bound can be obtained by calculating according to the second equation in (13) and computing the loss in (15). A few remarks on algorithm 1 are now in order.
Higher-order integrators. Algorithm 1 is stated for choice of forward-Euler integration for simplicity. In practice, any off-the-shelf integrator can be used, such as an adaptive Runge–Kutta method, by temporal discretization of the dynamics
and spatial discretization of the expectation over a set of samples propagated according to the equation for . In practice, the minimization can be performed over a parametric class of functions such as neural networks via a few steps of gradient descent.
Divergence computation. To avoid computation of the divergence—which can be costly for neural networks with high input dimension—we can use the denoising score matching loss function introduced by [61], which we discuss in appendix B.6. Empirically, we find that use of either the denoising objective or explicit derivative regularization is necessary for stable training to avoid overfitting to the training data; the level of regularization (or the noise scale in the denoising objective) can be decreased as the size of the dataset increases.
Time-dependence. When optimizing over a parametric class of functions, the score can be taken to be explicitly time-dependent, or the time-dependence can originate only through the parameters. In either case, all required outputs can be computed on-the-fly to avoid saving the entire history of parameters, which could be memory-intensive for large neural networks. If a time-dependent architecture is used, the method is amenable to online learning by randomly re-drawing initial conditions and optimizing over the resulting trajectory. In the numerical experiments below, we consider time-independent models with time-dependent parameters, because we found them to be sufficient.
SBTM vs. Sequential SBTM. Given the simplicity of the optimization problem (17), one may wonder if (15) is useful in practice, or if it is simply a stepping stone to arrive at (17). The primary difference is that (15) offers global control on the discrepancy between st and over , in the sense that it directly minimizes the time-integrated error, while (17) controls a local truncation error that could lead to the accumulation of learning and time-discretization errors. In the numerical examples below, we took the timestep sufficiently small, and the number of samples n sufficiently large, that we did not observe any accumulation of error. Nevertheless, (15) may allow for more accurate approximation, because the loss is exactly minimized at zero. Moreover, the higher-order derivatives contained in must remain well-behaved when using (15) because this term appears in the definition of , while (17) only contains .
3.3. Learning on external data
An alternative to the sequential procedure outlined here would be to generate samples from the target via simulation of the associated SDE (2), and then to approximate the score via minimization of the loss
similar to SBDM. ρt can be computed as in SBTM or sequential SBTM by simulation of the probability flow with the learned st . As we now show, neither nor are controlled when using this procedure.
Proposition 4 (Learning on external data). Let solve (10), and let solve (1). Then, the following equality holds
Proposition 4 shows that minimizing the error between st and on samples of leaves a remainder term, because in general . Young's inequality gives the simple upper bound
However, controlling the above quantity requires enforcing agreement between st and in addition to st and , which is precisely the idea of SBTM. Empirically, we find in our numerical experiments that training on external data alone is significantly less stable than sequential SBTM. In particular, and importantly for the applications we consider, we could not stably estimate the trajectory of the entropy production rate using a score model learned from the SDE with the same number of samples as used for sequential SBTM.
4. Numerical experiments
In the following, we study two high-dimensional examples from the physics of interacting particle systems, where the spatial variable of the FPE (1) can be written as with each . Here, describes a lower-dimensional ambient space, e.g. , so that the dimensionality of the FPE will be high if the number of particles N is even moderate 1 . The still figures shown in this section do not fully depict the complexity of the interacting particle dynamics, and we encourage the reader to view the movies available here. With a timestep , a horizon T = 10, and a fixed , we find that the sequential SBTM procedure takes around two hours for each simulation on a single NVIDIA RTX8000 GPU. In addition, study a low-dimensional example from the physics of active matter, which highlights the ability of sequential SBTM to remain stable over long times and to capture non-equilibrium probability currents. Our second and third examples go beyond the conditions required for existence and uniqueness assumed in section 1.2; nevertheless, due to the presence of a confining potential, solutions to the SDE (2), FPE (1), and probability flow (6) exist, as our numerical results show.
4.1. Harmonically interacting particles in a harmonic trap
Setup. Here we study a problem that admits a tractable analytical solution for direct comparison. We consider N two-dimensional particles () that repel according to a harmonic interaction but experience harmonic attraction towards a moving trap . The motion of the physical particles is governed by the stochastic dynamics
where is a fixed coefficient that sets the magnitude of the repulsion and each . The dynamics (21) is an OU process in the extended variable with block components . Assuming a Gaussian initial condition, the solution to the FPE associated with (21) is a Gaussian for all time and hence can be characterized entirely by its mean mt
and covariance Ct
. These can be obtained analytically (appendices
In the experiments, we take with a = 2, ω = 1, D = 0.25, α = 0.5, and N = 50, giving rise to a 100-dimensional FPE. The particles are initialized from an isotropic Gaussian with mean β0 (the initial trap position) and variance .
Network architecture. We take , where the potential is given as a sum of one- and two-particle terms
which ensures permutation symmetry amongst the physical particles by direct summation over all pairs. Modeling at the level of the potential introduces an additional gradient into the loss function, but makes it simple to enforce permutation symmetry; moreover, by writing the potential as a sum of one- and two-particle terms, the dimensionality of the function estimation problem is reduced. As motivation for this choice of architecture, we show in appendix D.1 that the class of scores representable by (23) contains the analytical score for the harmonic problem considered in this section. To obtain the parameters , we perform a warm start and initialize from , which reduces the number of optimization steps that need to be performed at each iteration. All networks are taken to be multi-layer perceptrons with the activation function [43]; further details on the architectures used can be found in appendix
Quantitative comparison. For a quantitative comparison between the learned model and the exact solution, we study the empirical covariance Σ over the samples and the entropy production rate . Because an analytical solution is available for this system, we may also compute the target and measure the goodness of fit via the relative Fisher divergence
In equation (24), can be taken to be equal to the current empirical estimate of ρt (the training data), or estimated using samples from the SDE(the SDE data).
Results. The representation of the dynamics (21) in terms of the flow of probability leads to an intuitive deterministic motion that accurately captures the statistics of the underlying stochastic process. Snapshots of particle trajectories from the learned probability flow (6), the SDE (21), and the noise-free equation obtained by setting D = 0 in (21) are shown in figure 1(A).
Results for this quantitative comparison are shown in figure 1(B). The learned model accurately predicts the entropy production rate of the system and minimizes the relative metric (24) to the order of 10−2. The noise-free system incorrectly predicts a constant and negative entropy production rate, while the SDE cannot make a prediction for the entropy production rate without an additional learning component; we study this possibility in the next example. In addition, the learned model accurately predicts the high-dimensional covariance Σ of the system (curves lie directly on top of the analytical result, trace shown for simplicity). The SDE also captures the covariance, but exhibits more fluctuations in the estimate; the noise-free system incorrectly estimates all covariance components as decaying to zero.
4.2. Soft spheres in an anharmonic trap
Setup. Here, we consider a system of N = 5 physical particles in an anharmonic trap in dimension that exhibit soft-sphere repulsion. This system gives rise to a 10-dimensional (1), which is significantly too high for standard PDE solvers. The stochastic dynamics is given by
where βt again represents a moving trap, A > 0 sets the strength of the repulsion between the spheres, r sets their size, B > 0 sets the strength of the trap, and each . We set or with , and r = 0.5. We fix with and γ = 5.0. This ensures that the trap scales with the number of particles and that they have sufficient room in the trap to generate a complex dynamics. The circular case converges to a distribution that can be described as a fixed distribution composed with a time-dependent rotation Qt , and hence the entropy production rate converges to zero by change of variables. The linear case does not exhibit this kind of convergence, and the entropy production rate should oscillate around zero as the particles are repeatedly pushed and pulled by the trap. We make use of the same network architecture as in section 4.1.
Results. Similar to section 4.1, an example trajectory from the learned system, the SDE (25), and the noise-free system obtained by setting D = 0 are shown in figure 2(A) in the circular case. The learned particle trajectories exhibit an intuitive circular motion when compared to the SDE trajectory. When compared to the noise-free system, the learned trajectories exhibit a greater amount of spread, which enables the deterministic dynamics to accurately capture the statistics of the stochastic dynamics. Numerical estimates of a single component of the covariance and of the entropy production rate are shown in figures 2(B)/(C), with all moments shown in appendix D.2. The learned and SDE systems accurately capture the covariance, while the noise-free system underestimates the covariance in both the linear and the circular case. The prediction of the entropy production rate via algorithm 1 is reasonable in both cases, exhibiting the expected convergence to and oscillation around zero in the circular and linear cases, respectively. In the inset, we show the prediction of the entropy production rate when learning on samples from the SDE; the prediction is initially offset, and later becomes divergent. We found that this behavior was generic when training on the SDE, but never observed it when training on self-consistent samples.
Download figure:
Standard image High-resolution image4.3. An active swimmer
Setup. We now consider a model from the physics of active matter, which describes the motion of a single motile swimmer in an anharmonic trap. The swimmer can be thought of as a run-and-tumble bacterium [59]; it travels in a fixed direction for a fluctuating duration before picking a new direction at random in which to swim. The system is two-dimensional, and is given by the SDE for the position x and velocity v
While low-dimensional, (26) exhibits convergence to a non-equilibrium statistical steady state in which the probability current is non-zero. Here, we show that sequential SBTM is capable of accurately capturing such currents, which is necessary to resolve the dynamics of the FPE: if our goal were solely to sample at equilibrium, it would be sufficient to freeze the samples after an initial transient. Moreover, we show that the method preserves the stationary distribution over long times relative to the persistence time of the swimmer, and does not display appreciable accumulation of error.
We set γ = 0.1 and D = 1.0. Because noise only enters the system through the velocity variable v in (26), the score can be taken to be one-dimensional, which is equivalent to learning the score only in the range of the rank-deficient diffusion matrix. Further details on the architecture can be found in appendix D.3.
Results. A phase portrait for the learned probability flow dynamics is shown in figure 3, computed by rolling out an additional set of 50 trajectories for time with a fixed set of parameters (after learning for time ). The phase portrait depicts closed limit cycles between and centered within the modes reminiscent of the classical phase portrait for the pendulum. Here, the closed limit cycles correspond to non-equilibrium currents that preserve the steady-state density.
Download figure:
Standard image High-resolution imageA kernel density estimate for the distribution of samples produced by the learned system, the stochastic system, and the noise-free systems are shown in figure 4, which demonstrate that the distribution of the learned samples qualitatively matches the distribution of the SDE samples. Comparatively, the noise-free system grows overly concentrated with time, ultimately converging to a singular dirac measure at the origin. A movie of the motion of the samples over a duration in phase space can be seen at this link. The movie highlights convergence of the learned solution to one with a non-zero steady-state probability current that qualitatively matches that of the SDE, but which enjoys more interpretable sample trajectories.
Download figure:
Standard image High-resolution image5. Outlook and conclusions
Building on the toolbox of score-based diffusion recently developed for generative modeling, we introduced a related approach—SBTM – that gives an alternative to simulating the corresponding SDE to solve the FPE. While SBTM is more costly than integration of the SDE because it involves a learning component, it gives access to quantities that are not directly accessible from the samples given by integrating the SDE, such as pointwise evaluation of the PDF, the probability current, or the entropy. Our numerical examples indicate that SBTM is scalable to systems in high dimension where standard numerical techniques for partial differential equations are inapplicable. The method can be viewed as a deterministic Lagrangian integration method for the FPE, and our results show that its trajectories are more easily interpretable than the corresponding trajectories of the SDE.
Acknowledgments
We thank Michael Albergo, Joan Bruna, Jonathan Niles-Weed, Stephen Tu, and Jean-Jacques Slotine for helpful discussions and feedback on the manuscript. N M B is partially supported by the Research Training Group in Modeling and Simulation funded by the National Science Foundation via Grant RTG/DMS—1646339. E V E is supported by the National Science Foundation under Awards DMR-1420073, DMS-2012510, and DMS-2134216, by the Simons Collaboration on Wave Turbulence, Grant No. 617006, and by a Vannevar Bush Faculty Fellowship.
Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files).
Appendix A: Some basic formulas
Here, we derive some results linking the solution of the transport equation (10) with that of the probability flow equation (6).
A.1. Probability density and probability current
We begin with a lemma.
Lemma 5. Let satisfy the transport equation
Assume that is C2 in both t and x for and globally Lipschitz in x. Then, given any , the solution of (A.1) satisfies
where is the probability flow solution to (6). In addition, given any test function , we have
In words, lemma 5 states that an evaluation of the PDF ρt at a given point x may be obtained by evolving the probability flow equation (6) backwards to some earlier time tʹ to find the point xʹ that evolves to x at time t, assuming that is available. In particular, for , we obtain
and
Since the probability current is by definition , using (A.4) to express also gives the following equation for the current:
Proof. The assumed C2 and globally Lipschitz conditions on vt guarantee global existence (on ) and uniqueness of the solution to (6). Differentiating with respect to t and using (6) and (A.1) we deduce
Integrating this equation in t from to t = t gives
Evaluating this expression at and using the group properties (i) and (ii) gives (A.2). Equation (A.3) can be derived by using (A.2) to express in the integral at the left hand-side, changing integration variable and noting that the factor is precisely the Jacobian of this change of variable. To see this, note that by definition the flow map satisfies
Hence,
By Jacobi's formula for determinants,
Integrating this equation with respect to t and using that , we obtain
The result is the integral at the right hand-side of (A.3).
Lemma 5 also holds locally in time for any that is C2 in both t and x. In particular, it holds locally if we set and if we assume that is (i) positive everywhere on Ω and (ii) C3 in x. In this case, (A.1) is the FPEs (1) and (A.2) holds for the solution to that equation.
A.2. Calculation of the differential entropy
We now consider computation of the differential entropy, and state a similar result.
Lemma 6. Assume that is positive everywhere on Ω and C3 in its argument. Let denote the solution to the FPE (1) (or equivalently, to the transport equation (A.1) with in the definition of ). Then the differential entropy can expressed as
or
Proof. We first derive (A.9). Observe that applying (A.5) with leads to the first equality. The second can then be deduced from (A.4). To derive (A.10), notice that from (A.1),
Above, we used integration by parts to obtain the second equality and to get the third. Now, using (A.5) with integrating the result gives (A.10).
A.3. Resampling of ρt at any time t
If the score is known to sufficient accuracy, ρt can be resampled at any time t using the dynamics
In (A.12), τ is an artificial time used for sampling that is distinct from the physical time in (2). For , the equilibrium distribution of (A.12) is exactly ρt . In practice, st will be imperfect and will have an error that increases away from the samples used to learn it; as a result, (A.12) should be used near samples for a fixed amount of time to avoid the introduction of additional errors.
Appendix B: Further details on score-based transport modeling
B.1. Bounding the KL divergence
Let us restate proposition 1 for convenience:
Proposition 1 (Control of the KL divergence). Assume that the conditions listed in section 1.2 hold. Let ρt denote the solution to the transport equation (10), and let denote the solution to the FPE (1). Assume that for all . Then
where .
Proof. By assumption, ρt solves (10) and solves (1). Denote by and with . Then, we have
Above, we used integration by parts to obtain the third equality. Now, dropping function arguments for simplicity of notation, we have that
Hence, we deduce that
B.2. SBTM in the Eulerian frame
The Eulerian equivalent of proposition 2 can be stated as:
Proposition 7 (SBTM in the Eulerian frame). Assume that the conditions listed in section 1.2 hold. Fix and consider the optimization problem
with . Then every minimizer of (B.2) satisfies where solves (1).
In words, this proposition states that solving the constrained optimization problem (B.2) is equivalent to solving the FPE (1).
Proof. The constrained minimization problem (B.2) can be handled by considering the extended objective
where and is a Lagrange multiplier. The Euler–Lagrange equations associated with (B.3) read
Clearly, these equations will be satisfied if for all , for all x, and solves (1). This solution is also a global minimizer, because it zeroes the value of the objective. Moreover, all global minimizers must satisfy (almost everywhere), as this is the only way to zero the objective.
It is also easy to see that there are no other local minimizers. To check this, we can use the fourth equation to write
Then,
This reduces the first three equations to
Since the equation for µt is homogeneous in µt and , we must have for all , and the equation for ρt reduces to (1).
B.3. SBTM in the Lagrangian frame
As stated, proposition 7 is not practical, because it is phrased in terms of the density ρt . The following result demonstrates that the transport map identity (7) can be used to re-express proposition 7 entirely in terms of known quantities.
Proposition 2 (Score-based transport modeling). Assume that the conditions listed in section 1.2 hold. Define and consider
Then solves (10), the equality holds, and for any
Moreover, if is a minimizer of the constrained optimization problem
then where solves the FPE (1). The map associated to any minimizer is a transport map from ρ0 to , i.e.
Proof. Let us first show that satisfies (13) if i.e. if ρt satisfies the transport equation (10). Since (10) implies that
taking the gradient gives
Therefore solves
which recovers the equation for in (13). Hence, the objective in (15) can also be written as
where the second equality follows from (A.5) if satisfies (A.1). Hence, (15) is equivalent to (B.2). The bound on follows from (12).
Adjoint equations. In terms of a practical implementation, the objective in (B.2) can be evaluated by generating samples from ρ0 and solving the equations for Xt and Gt using the initial conditions and . Note that evaluating this second initial condition only requires one to know ρ0 up to a normalization factor. To evaluate the gradient of the objective, we can introduce equations adjoint to those for Xt and Gt . To do so, we can consider the extended objective
Taking the first variation with respect to and , respectively, gives the equations
B.4. Sequential SBTM
Let us restate proposition 3 for convenience:
Proposition 3 (Sequential SBTM). In the same setting as proposition 2, let solve the first equation in (13) with . Let st be obtained via
Then, each minimizer of (17) satisfies where is the solution to (1). Moreover, the map associated to is a transport map from ρ0 to .
Proof. If , then by definition we have the identity
This means that the optimization problem in (17) is equivalent to
All minimizers of this optimization problem satisfy . Hence, by (10),
B.5. Learning from the SDE
In this section, we show that learning from the SDE alone—i.e. avoiding the use of self-consistent samples—does not provide a guarantee on the accuracy of ρt . We have already seen in (12) that it is sufficient to control to control . The proof of proposition 1 shows that control on
as would be provided by training on samples from the SDE, does not ensure control on . The following proposition shows that control on (B.14) does not guarantee control on either. An analogous result appeared in [34] in the context of SBDM for generative modeling; here, we provide a self-contained treatment to motivate the use of the sequential SBTM procedure discussed in the main text.
Proposition 4 (Learning on external data). Let solve (10), and let solve (1). Then, the following equality holds
Proof. By an analogous argument as in the proof of proposition 1, we find
Adding and subtracting to the first term in the inner product and expanding gives
Integrating from 0 to T completes the proof.
B.6. Denoising loss
The following standard trick can be used to avoid computing the divergence of :
The expectation of the first term on the right-hand side of this equation is zero; the expectation of the second gives the result in (B.16). Hence, taking the expectation of (B.17) and evaluating the result in the limit as gives the first equation in (B.16). The second equation in (B.16) can be proven similarly using .
Replacing in (17) with the first expression in (B.17) for a fixed α > 0 gives the loss
Evaluating the square term at a perturbed data point recovers the denoising loss of Vincent [61]
We can improve the accuracy of the approximation with a 'doubling trick' that applies two draws of the noise of opposite sign to reduce the variance. This amounts to replacing the expectations in (B.16) with
whose limits as α → 0 are and , respectively. In practice, we observe that this approach always helps stabilize training. Moreover, we observe that use of the denoising loss also stabilizes training, so that it is preferable to full computation of even when the latter is feasible.
Appendix C: Gaussian case
Here, we consider the case of an OU process where the score can be written analytically, thereby providing a benchmark for our approach. The example treated in section 4.1 with details in appendix D.1 is a special case of such an OU process with additional symmetry arising from permutations of the particles. The SDE reads
where , is a time-dependent positive-definite tensor (not necessarily symmetric), is a time-dependent vector, and is a time-dependent tensor. The FPE associated with (C.1) is
where . Assuming that the initial condition is Gaussian, with positive-definite, the solution is Gaussian at all times , with mt and solutions to
This implies in particular that
so that the probability flow equation for Xt and the equation for Gt written in (13) read
with initial condition and . It is easy to see that with we have since, from the first equation in (C.5), the mean and variance of Xt satisfy (C.3). Similarly, when , , so that because the second equation in (C.5) is linear and hence preserves Gaussianity. Moreover, and satisfies
The solution to this equation is since substituting this ansatz into (C.6) gives the equation for that we can deduce from (C.3)
Note that if , , and are all time-independent, then with and the solution to the Lyapunov matrix equation
This means that at long times the coefficients at the right-hand sides of (C.5) also settle on constant values. However, Xt and Gt do not necessarily stop evolving; one situation where they too converge is when the OU process is in detailed balance, i.e. when for some positive-definite. In that case, the solution to (C.8) is and it is easy to see that at long times the right-hand sides of (C.5) tend to zero.
Remark 9. This last conclusion is actually more generic than for a simple OU process. For any SDE in detailed balance, i.e. that can be written as
where is a C2-potential such that , we have that , and the corresponding flows Xt and Gt eventually stop as . In this case, ρt follows gradient descent in W2 over the energy
The unique PDF minimizing this energy is , and as Xt converges towards a transport map between the initial ρ0 and .
Appendix D: Experimental details and additional examples
All numerical experiments were performed in using the package to implement the networks and the package for optimization.
D.1. Harmonically interacting particles in a harmonic trap
Network architecture. Both the single-particle energy and two-particle interaction energy are parameterized as single hidden-layer neural networks with the swish activation function [43] and hidden neurons. The hidden layer biases are initialized to zero while the hidden layer weights are initialized from a truncated normal distribution with variance , following the guidelines recommended in [21].
Optimization. The Adam [23] optimizer is used with an initial learning rate of and otherwise default settings. At time t = 0, the analytical relative loss
is minimized to a value less than 10−4 using knowledge of the initial condition with . In (D.1), the expectation with respect to ρ0 is approximated by an initial set of samples with drawn from ρ0. In the experiments, we set n = 100, which we found to be sufficient to obtain a few digits of relative accuracy on various quantities of interest. We set the physical timestep and take steps of Adam on the standard sequential SBTM loss function (17) until the norm of the gradient is below .
Analytical moments. First define the mean, second moment, and covariance according to
It is straightforward to show that the mean and covariance obey the dynamics
Because the particles are indistinguishable so long as they are initialized from a distribution that is symmetric with respect to permutations of their labeling, the moments will satisfy the ansatz
The dynamics for the vector , as well as the matrices and can then be obtained from (D.2) and (D.3) as
For a given , these equations can be solved analytically in Mathematica as a function of time, giving the mean and covariance . Because the solution is Gaussian for all t, we then obtain the analytical solution to the FPE and the corresponding analytical score .
Potential structure. Here, we show that the potential for this example lies in the class of potentials described by (23). From equation (D.5), we have a characterization of the structure of the covariance matrix Ct for the analytical potential . In particular, Ct is block circulant, and hence is block diagonalized by the roots of unity (the block discrete Fourier transform). That is, we may take a 'block eigenvector' of the form with for . By direct calculation, this block diagonalization leads to two distinct block eigenmatrices,
where denotes the matrix with block columns ωk . The inverse matrix then must similarly have only two distinct block eigenmatrices given by and . By inversion of the block Fourier transform, we then find that
for some matrices . Hence, by direct calculation
Above, we may identify the first term in the last line as and the second term in the last line as . Moreover, is symmetric with respect to its arguments.
Analytical entropy. For this example, the entropy can be computed analytically and compared directly to the learned numerical estimate. By definition,
Additional figures. Images of the learned velocity field and potential in comparison to the corresponding analytical solutions can be found in figures D1 and D2, respectively. Further detail can be found in the corresponding captions. We stress that the two-dimensional images represent single-particle slices of the high-dimensional functions.
Download figure:
Standard image High-resolution imageDownload figure:
Standard image High-resolution imageD.2. Soft spheres in an anharmonic trap
Network architecture. Both potential terms and are modeled as four hidden-layer deep fully connected networks with neurons in each layer. The initialization is identical to appendix D.2.
Optimization and initialization. The Adam optimizer is used with an initial learning rate of and otherwise default settings. At time t = 0, the loss (D.1) is minimized to a value less than 10−6 over n samples , with and . Past this initial stage, the denoising loss is used with a noise scale σ = 0.1; we found that a higher noise scale regularized the problem and led to a smoother prediction for the entropy, at the expense of a slight bias in the moments. By increasing the number of samples n, the noise scale can be reduced while maintaining an accurate prediction for the entropy. The loss is minimized by taking steps of Adam at each timestep. The physical timestep is set to .
Additional figures. Figures D3 and D4 show the full grid of covariance components for the SDE, learned, and noise free systems. The noise free underestimates the moments, while the learned and SDE agree well.
Download figure:
Standard image High-resolution imageDownload figure:
Standard image High-resolution imageD.3. An active swimmer
Setup. We parameterize the score directly using a three hidden layer neural network with neurons per hidden layer. Because the dynamics is anti-symmetric, we impose that .
Optimization and initialization. The network initialization is identical to the previous two experiments. The physical timestep is set to . The Adam optimizer is used with an initial learning rate of . At time t = 0 the loss (D.1) is minimized to a tolerance of 10−4 over samples drawn from an initial distribution with . The denoising loss is used with a noise scale σ = 0.05, using steps of Adam until the norm of the gradient is below .
Footnotes
- 1
We would like to emphasize at this stage the difference between the number of physical particles N, which is a parameter for the system under study and sets the dimensionality of the resulting FPE, and the number of algorithmic samples n, which is a hyper-parameter that can be chosen at will to improve the accuracy of the learning.