summaries: The paper tackles the problem of learning flow-based generative models. The proposed approach, a new instance of continuous normalizing-flow methods, models the density as a difference between the prior and a divergence term, parameterized by a neural network.  The claims are that: * MF constitutes a universal density approximator, * MF is more efficient to train than alternative CNFs; this is demonstrated empirically and the intuition is that MF does not require invoking or backpropagating through an ODE during training (note however that solving an ODE is required for sampling), * MF improves upon alternative CNFs in terms of density estimation, sample quality, and training complexity, * MF demonstrates for the first time the use of flow models for sampling from general curved surfaces. This paper proposes an alternative way to train a continuous normalizing flow (CNF), inspired by the Dacorogna-Moser transport. The proposed training does not require numerical integration; instead, the likelihood of the flow can be directly evaluated by computing the divergence of the mass flow rate. The idea is tested on boundaryless manifolds, such as the flat torus for toy data and implicit surfaces.  The paper introduces a new type of continuous normalizing flow (CNF) for manifold-valued data. Unlike in previous works, this Moser Flow (MF) models a density as a base density minus the divergence of a neural network. The authors prove that under certain assumptions this defines a probability distribution over the manifold. This approach has a different trade-off between inference and generation from other approaches: while the model density can be evaluated very cheaply, sampling from this model requires an ODE solver. The approach is qualitatively demonstrated on toy datasets on tori and the Stanford bunny, and quantitatively evaluated on a few datasets on 2-spheres. This paper presents Moser Flow a new class of Continuous Normalizing Flows for Riemannian Manifolds. The main approach exploits results in differential geometry (Moser 1965) to construct a vector field that satisfies the normalizing equation given by the pullback of the volume form under $\Phi$. The approach is both sensible and provides direct advantages over Riemmanian CNF's as training does not require solving the ODE using a solver. The authors also consider Moser Flows for Euclidean Submanifolds under the Induced metric and show that Moser Flows can learn arbitrary distributions on manifolds of interest (---i.e. compact, boundryless etc...). Finally, the experiments conducted are both interesting in their variety and illuminating in that they show the effectiveness of the proposed method. Overall, this paper represents a non-trivial step forward---manifold or otherwise---for Continuous Normalizing Flow research. The authors define a continuous normalizing flow on an arbitrary Riemannian manifold through the divergence of a neural network using the Moser theorem. They motivate their approach and show how this flow can be represented and learned. By applying their method to a toy distributions and a real world earth and climate dataset, they demonstrate the effectiveness of the method and that they can outperform competing procedures. Furthermore, they show that their method is much faster and more efficient than FFJORD when learning a complex two dimensional density.
abstractText: We are interested in learning generative models for complex geometries described via manifolds, such as spheres, tori, and other implicit surfaces. Current extensions of existing (Euclidean) generative models are restricted to specific geometries and typically suffer from high computational costs. We introduce Moser Flow (MF), a new class of generative models within the family of continuous normalizing flows (CNF). MF also produces a CNF via a solution to the change-of-variable formula, however differently from other CNF methods, its model (learned) density is parameterized as the source (prior) density minus the divergence of a neural network (NN). The divergence is a local, linear differential operator, easy to approximate and calculate on manifolds. Therefore, unlike other CNFs, MF does not require invoking or backpropagating through an ODE solver during training. Furthermore, representing the model density explicitly as the divergence of a NN rather than as a solution of an ODE facilitates learning high fidelity densities. Theoretically, we prove that MF constitutes a universal density approximator under suitable assumptions. Empirically, we demonstrate for the first time the use of flow models for sampling from general curved surfaces and achieve significant improvements in density estimation, sample quality, and training complexity over existing CNFs on challenging synthetic geometries and real-world benchmarks from the earth and climate sciences.
authors.name: Noam Rozen
authors.name: Aditya Grover
authors.name: Maximilian Nickel
authors.name: Yaron Lipman
references.authors: A.H. Al-Mohy N.J. Higham
references.title: A New Scaling and Squaring Algorithm for the Matrix Exponential
references.venue: SIAM Journal on Matrix Analysis and Applications,
references.authors: A.J. Bose A. Smofsky R. Liao P. Panangaden W.L. Hamilton
references.title: Latent Variable Modelling with Hyperbolic Normalizing Flows
references.authors: T.B. Brown B. Mann N. Ryder M. Subbiah J. Kaplan P. Dhariwal A. Neelakantan P. Shyam G. Sastry A Askell
references.title: Language models are few-shot learners. arXiv preprint arXiv:2005.14165
references.authors: M. Chen B. Tu B. Lu
references.title: Triangulated manifold meshing method preserving molecular surface topology
references.venue: Journal of Molecular Graphics and Modelling,
references.authors: R.T. Chen Y. Rubanova J. Bettencourt D. Duvenaud
references.title: Neural ordinary differential equations. arXiv preprint arXiv:1806.07366
references.authors: R.T.Q. Chen J. Behrmann D. Duvenaud Jacobsen J.-H
references.title: Residual flows for invertible generative modeling
references.authors: B. Dacorogna J. Moser
references.title: On a partial differential equation involving the jacobian determinant
references.venue: In Annales de l’Institut Henri Poincare (C) Non Linear Analysis,
references.authors: P. Dhariwal A. Nichol
references.title: Diffusion models beat gans on image synthesis
references.venue: arXiv preprint arXiv:2105.05233
references.authors: L. Dinh J. Sohl-Dickstein S. Bengio
references.title: Density estimation using real nvp
references.venue: arXiv preprint arXiv:1605.08803
references.authors: A. Dooley N. Wildberger
references.title: Harmonic analysis and the global exponential map for compact Lie groups
references.venue: Functional Analysis and Its Applications,
references.authors: L. Falorsi P. Forré
references.title: Neural Ordinary Differential Equations on Manifolds. arXiv:2006.06663 [cs, stat
references.authors: S. Gerber T. Tasdizen P.T. Fletcher S. Joshi R. Whitaker Initiative A.D. N
references.title: Manifold modeling for brain population analysis
references.venue: Medical image analysis,
references.authors: W. Grathwohl R.T.Q. Chen J. Bettencourt I. Sutskever D. Duvenaud
references.title: Ffjord: Free-form continuous dynamics for scalable reversible generative models
references.authors: A. Gropp L. Yariv N. Haim M. Atzmon Y. Lipman
references.title: Implicit geometric regularization for learning shapes
references.authors: H. Hoppe T. DeRose T. Duchamp J. McDonald W. Stuetzle
references.title: Surface reconstruction from unorganized points
references.venue: In Proceedings of the 19th annual conference on computer graphics and interactive techniques,
references.authors: Huang C.-W R.T.Q. Chen C. Tsirigotis A. Courville
references.title: Convex potential flows: Universal probability distributions with optimal transport and convex optimization
references.authors: M. Kazhdan M. Bolitho H. Hoppe
references.title: Poisson surface reconstruction
references.venue: In Proceedings of the fourth Eurographics symposium on Geometry processing,
references.authors: D.P. Kingma J. Ba
references.title: Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980
references.authors: M. Kumar M. Babaeizadeh D. Erhan C. Finn S. Levine L. Dinh D. Kingma
references.title: Videoflow: A flow-based generative model for video
references.venue: arXiv preprint arXiv:1903.01434,
references.authors: J.M. Lee
references.title: Smooth manifolds. In Introduction to Smooth Manifolds, pages
references.authors: W.E. Lorensen H.E. Cline
references.title: Marching cubes: A high resolution 3d surface construction algorithm
references.venue: ACM siggraph computer graphics,
references.authors: A. Lou D. Lim I. Katsman L. Huang Q. Jiang Lim S.-N C. De Sa
references.title: Neural manifold ordinary differential equations
references.authors: E. Mathieu M. Nickel
references.title: Riemannian continuous normalizing flows. arXiv preprint arXiv:2006.10605
references.authors: J. Moser
references.title: On the volume elements on a manifold
references.venue: Transactions of the American Mathematical Society,
references.authors: G. Papamakarios E. Nalisnick D.J. Rezende S. Mohamed B. Lakshminarayanan
references.title: Normalizing flows for probabilistic modeling and inference. arXiv preprint arXiv:1912.02762
references.authors: D. Rezende S. Mohamed
references.title: Variational inference with normalizing flows
references.venue: In International Conference on Machine Learning,
references.authors: D.J. Rezende G. Papamakarios S. Racaniere M. Albergo G. Kanwar P. Shanahan K. Cranmer
references.title: Normalizing flows on tori and spheres
references.venue: In International Conference on Machine Learning,
references.authors: T. Sei
references.title: A Jacobian Inequality for Gradient Maps on the Sphere and Its Application to Directional Statistics. Communications in Statistics - Theory and Methods, 42(14):2525–2542
references.authors: M. Tancik P.P. Srinivasan B. Mildenhall S. Fridovich-Keil N. Raghavan U. Singhal R. Ramamoorthi J.T. Barron R. Ng
references.title: Fourier features let networks learn high frequency functions in low dimensional domains
sections.heading: 1 Introduction
sections.text: The major successes of deep generative models in recent years are primarily in domains involving Euclidean data, such as images (Dhariwal and Nichol, 2021), text (Brown et al., 2020), and video (Kumar et al., 2019). However, many kinds of scientific data in the real world lie in non-Euclidean spaces specified as manifolds. Examples include planetary-scale data for earth and climate sciences (Mathieu and Nickel, 2020), protein interactions and brain imaging data for life sciences (Gerber et al., 2010; Chen et al., 2012), as well as 3D shapes in computer graphics (Hoppe et al., 1992; Kazhdan et al., 2006). Existing (Euclidean) generative models cannot be effectively applied in these scenarios as they would tend to assign some probability mass to areas outside the natural geometry of these domains.
  An effective way to impose geometric domain constraints for deep generative modeling is to design normalizing flows that operate in the desired manifold space. A normalizing flow maps a prior (source) distribution to a target distribution via the change of variables formula (Rezende and Mohamed, 2015; Dinh et al., 2016; Papamakarios et al., 2019). Early work in this direction proposed invertible architectures for learning probability distributions directly over the specific manifolds defined over spheres and tori (Rezende et al., 2020). Recently, Mathieu and Nickel (2020) proposed to extend continuous normalizing flows (CNF) (Chen et al., 2018) for generative modeling over Riemannian manifolds wherein the flows are defined via vector fields on manifolds and computed as the solution to an associated ordinary differential equation (ODE). CNFs have the advantage that the neural
  35th Conference on Neural Information Processing Systems (NeurIPS 2021).
  network architectures parameterizing the flow need not be restricted via invertibility constraints. However, as we show in our experiments, existing CNFs such as FFJORD (Grathwohl et al., 2018) and Riemannian CNFs (Mathieu and Nickel, 2020) can be slow to converge and the generated samples can be inferior in capturing the details of high fidelity data densities. Moreover, it is a real challenge to apply Riemannian CNFs to complex geometries such as general curved surfaces.
  To address these challenges, we propose Moser Flows (MF), a new class of deep generative models within the CNF family. An MF models the desired target density as the source density minus the divergence of an (unrestricted) neural network. The divergence is a local, linear differential operator, easy to approximate and calculate on manifolds. By drawing on classic results in differential geometry by Moser (1965) and Dacorogna and Moser (1990), we can show that this parameterization induces a CNF solution to the change-of-variables formula specified via an ODE. Since MFs directly parameterize the model density using the divergence, unlike other CNF methods, we do not require to explicitly solve the ODE for maximum likelihood training. At test-time, we use the ODE solver for generation. We derive extensions to MFs for Euclidean submanifolds that efficiently parameterize vector fields projected to the desired manifold domain. Theoretically, we prove that Moser Flows are universal generative models over Euclidean submanifolds. That is, given a Euclidean submanifold M and a target continuous positive probability density µ overM, MFs can push arbitrary positive source density ν overM to densities µ̄ that are arbitrarily close to µ. We evaluate Moser Flows on a wide range of challenging real and synthetic problems defined over many different domains. On synthetic problems, we demonstrate improvements in convergence speed for attaining a desired level of details in generation quality. We then experiment with two kinds of complex geometries. First, we show significant improvements of 49% on average over Riemannian CNFs (Mathieu and Nickel, 2020) for density estimation as well as high-fidelity generation on 4 earth and climate science datasets corresponding to global locations of volcano eruptions, earthquakes, floods, and wildfires on spherical geometries. Next and last, we go beyond spherical geometries to demonstrate for the first time, generative models on general curved surfaces.
sections.heading: 2 Preliminaries
sections.text: Riemannian manifolds. We consider an orientable, compact, boundaryless, connected ndimensional Riemannian manifoldM with metric g. We denote points in the manifold by x, y ∈M. At every point x ∈ M, TxM is an n-dimensional tangent plane toM. The metric g prescribes an inner product on each tangent space; for v, u ∈ TxM, their inner product w.r.t. g is denoted by 〈v, u〉g. X(M) is the space of smooth (tangent) vector fields toM; that is, if u ∈ X(M) then u(x) ∈ TxM, for all x ∈ M, and if u written in local coordinates it consists of smooth functions. We denote by dV the Riemannian volume form, defined by the metric g over the manifoldM. In particular, V (A) = ∫ A dV is the volume of the set A ⊂M.
  We consider probability measures overM that are represented by strictly positive continuous density functions µ, ν :M→ R>0, where µ by convention represents the target (unknown) distribution and ν represents the source (prior) distribution. µ, ν are probability densities in the sense their integral w.r.t. the Riemannian volume form is one, i.e., ∫ M µdV = 1 = ∫ M νdV . It is convenient to consider the volume forms that correspond to the probability measures, namely µ̂ = µdV and ν̂ = νdV . Volume forms are differential n-forms that can be integrated over subdomains ofM, for example, pν(A) = ∫ A ν̂ is the probability of the event A ⊂M.
  Continuous Normalizing Flows (CNF) on manifolds operate by transforming a simple source distribution through a map Φ into a highly complex and multimodal target distribution. A manifold CNF, Φ :M→M, is an orientation preserving diffeomorphism from the manifold to itself (Mathieu and Nickel, 2020; Lou et al., 2020; Falorsi and Forré, 2020). A smooth map Φ :M→M can be used to pull-back the target µ̂ according to the formula:
  (Φ∗µ̂)z(v1, . . . , vn) = µ̂Φ(z)(DΦz(v1), . . . , DΦz(vn)), (1)
  where v1, . . . , vn ∈ TzM are arbitrary tangent vectors, DΦz : TzM→ TΦ(z)M is the differential of Φ, namely a linear map between the tangent spaces toM at the points z and Φ(z), respectively. By pulling-back µ̂ according to Φ and asking it to equal to the prior density ν, we get the manifold version of the standard normalizing equation:
  ν̂ = Φ∗µ̂. (2)
  If the normalizing equation holds, then for an event A ⊂M we have that pν(A) = ∫ A ν̂ = ∫ A Φ∗µ̂ = ∫ Φ(A) µ̂ = pµ(Φ(A)).
  Therefore, given a random variable z distributed according to ν, then x = Φ(z) is distributed according to µ, and Φ is the generator.
  One way to construct a CNF Φ is by solving an ordinary differential equation (ODE) (Chen et al., 2018; Mathieu and Nickel, 2020). Given a time-dependent vector field vt ∈ X(M) with t ∈ [0, 1], a one-parameter family of diffeomorphisms (CNFs) Φt : [0, 1]×M→M is defined by
  d dt Φt = vt(Φt), (3)
  where this ODE is initialized with the identity transformation, i.e., for all x ∈ M we initialize Φ0(x) = x. The CNF is then defined by Φ(x) = Φ1(x).
  Example: Euclidean CNF. Let us show how the above notions boil down to standard Euclidean CNF for the choice ofM = Rn, and the standard Euclidean metric; we denote z = (z1, . . . , zn) ∈ Rn. The Riemannian volume form in this case is dz = dz1∧dz2∧· · ·∧dzn. Furthermore, µ̂(z) = µ(z)dz and ν̂(z) = ν(z)dz. The pull-back formula (equation 1) in coordinates (see e.g., Proposition 14.20 in Lee (2013)) is
  Φ∗µ̂(z) = µ(Φ(z)) det(DΦz)dz,
  where DΦz is the matrix of partials of Φ at point z, (DΦz)ij = ∂Φ i
  ∂zj (z). Plugging this in equation 2 we get the Euclidean normalizing equation:
  ν(z) = µ(Φ(z)) det(DΦz). (4)
sections.heading: 3 Moser Flow
sections.text: Moser (1965) and Dacorogna and Moser (1990) suggested a method for solving the normalizing equation, that is equation 2. Their method explicitly constructs a vector field vt, and the flow it defines via equation 3 is guaranteed to solve equation 2. We start by introducing the method, adapted to our needs, followed by its application to generative modeling. We will use notations introduced above.
sections.heading: 3.1 Solving the normalizing equation
sections.text: Moser’s approach to solving equation 2 starts by interpolating the source and target distributions. That is, choosing an interpolant αt : [0, 1]×M→ R>0, such that α0 = ν, α1 = µ, and ∫ M αtdV = 1 for all t ∈ [0, 1]. Then, a time-dependent vector field vt ∈ X(M) is defined so that for each time t ∈ [0, 1], the flow Φt defined by equation 3 satisfies the continuous normalization equation:
  Φ∗t α̂t = α̂0, (5)
  where α̂t = αtdV is the volume form corresponding to the density αt. Clearly, plugging t = 1 in the above equation provides a solution to equation 2 with Φ = Φ1. As it turns out, considering the continuous normalization equation simplifies matters and the sought after vector field vt is constructed as follows. First, solve the partial differential equation (PDE) over the manifoldM
  div(ut) = − d
  dt αt, (6)
  where ut ∈ X(M) is an unknown time-dependent vector field, and div is the Riemannian generalization to the Euclidean divergence operator, divE = ∇·. This manifold divergence operator is defined by replacing the directional derivative of the Euclidean space with its Riemannian version, namely the covariant derivative,
  div(u) = n∑ i=1 〈∇eiu, ei〉g , (7)
  where {ei}ni=1 is an orthonormal frame according to the Riemannian metric g, and ∇ξu is the Riemannian covariant derivative. Note that here we assume thatM is boundaryless, otherwise we need ut to be also tangent to the boundary ofM. Second, define
  vt = ut αt . (8)
  Theorem 2 in Moser (1965) implies:
  Theorem 1 (Moser). The diffeomorphism Φ = Φ1, defined by the ODE in equation 3 and vector field vt in equation 8 solves the normalization equation, i.e., equation 2.
  The proof of this theorem in our case is provided in the supplementary for completeness. A simple choice for the interpolant αt that we use in this paper was suggested in Dacorogna and Moser (1990):
  αt = (1− t)ν + tµ. (9)
  The time derivative of this interpolant, i.e., ddtαt = µ − ν, does not depend on t. Therefore the vector field can be chosen to be constant over time, ut = u, and the PDE in equation 6 takes the form div(u) = ν − µ, (10) and consequently vt takes the form
  vt = u
  (1− t)ν + tµ . (11)
  Figure 1 shows a one dimensional illustration of Moser Flow.
sections.heading: 3.2 Generative model utilizing Moser Flow
sections.text: We next utilize MF to define our generative model. Our model (learned) density µ̄ is motivated from equation 10 and is defined by µ̄ = ν − div(u), (12) where u ∈ X(M) is the degree of freedom of the model. We model this degree of freedom, u, with a deep neural network, more specifically, Multi-Layer Perceptron (MLP). We denote θ ∈ Rp the learnable parameters of u. We start by noting that, by construction, µ̄ has a unit integral overM: Lemma 1. IfM has no boundary, or u|∂M ∈ X(∂M), then ∫ M µ̄dV = 1.
  This lemma is proved in the supplementary and a direct consequence of Stokes’ Theorem. If µ̄ > 0 overM then, together with the fact that ∫ M µ̄dV = 1 (Lemma 1), it is a probability density overM. Consequently, Theorem 1 implies that µ̄ is realized by a CNF defined via vt:
  Corollary 1. If µ̄ > 0 overM then µ̄ is a probability distribution overM, and is generated by the flow Φ = Φ1, where Φt is the solution to the ODE in equation 3 with the vector field vt ∈ X(M) defined in equation 11.
  Since µ̄ > 0 is an open constraint and is not directly implementable, we replace it with the closed constraint µ̄ ≥ , where > 0 is a small hyper-parameter. We define
  µ̄+(x) = max { , µ̄(x)} ; µ̄−(x) = −min { , µ̄(x)} .
  As can be readily verified: µ̄+, µ̄− ≥ 0, and µ̄ = µ̄+ − µ̄−. (13)
  We are ready to formulate the loss for training the generative model. Consider an unknown target distribution µ, provided to us as a set of i.i.d. observations X = {xi}mi=1 ⊂ M. Our goal is to maximize the likelihood of the data X while making sure µ̄ ≥ . We therefore consider the following loss:
  `(θ) = −Eµ log µ̄+(x) + λ ∫ M µ̄−(x)dV (14)
  where λ is a hyper-parameter. The first term in the loss is approximated by the empirical mean computed with the observations X , i.e.,
  Ex∼µ log µ̄+(x) ≈ 1
  m m∑ i=1 log µ̄+(xi).
  This term is merely the negative log likelihood of the observations.
  The second term in the loss penalizes the deviation of µ̄ from satisfying µ̄ ≥ . According to Theorem 1, this measures the deviation of µ̄ from being a density function and realizing a CNF. One point that needs to be verified is that the combination of these two terms does not push the minimum away from the target density µ. This can be verified with the help of the generalized Kullback–Leibler (KL) divergence providing a distance measure between arbitrary positive functions f, g :M→ R>0:
  D(f, g) = ∫ M f log ( f g ) dV − ∫ M fdV + ∫ M gdV. (15)
  Using the generalized KL, we can now compute the distance between the positive part of our model density, i.e., µ̄+, and the target density:
  D(µ, µ̄+) = Eµ log ( µ
  µ̄+ ) − ∫ M µdV + ∫ M µ̄+dV
  = Eµ logµ− Eµ log µ̄+ + ∫ M µ̄−dV
  where in the second equality we used Lemma 1. The term Eµ logµ is the negative entropy of the unknown target distribution µ. The loss in equation 14 equals D(µ, µ̄+) − Eµ logµ + (λ − 1) ∫ M µ̄−dV . Therefore, if λ ≥ 1, and minx∈M µ(x) > (we use the compactness ofM to infer existence of such a minimal positive value), then the unique minimum of the loss in equation 14 is the target density, i.e., µ̄ = µ. Indeed, the minimal value of this loss is −Eµ logµ and it is achieved by setting µ̄ = µ. Uniqueness follows by considering an arbitrary minimizer µ̄. Since such a minimizer satisfies D(µ, µ̄+) = 0 and ∫ M µ̄−dV = 0, necessarily µ̄ = µ. We proved: Theorem 2. For λ ≥ 1 and sufficiently small > 0, the unique minimizer of the loss in equation 14 is µ̄ = µ. Variation of the loss. Lemma 1 and equation 13 imply that ∫ M µ̄+dV = ∫ M µ̄−dV +1. Therefore, an equivalent loss to the one presented in equation 14 is:
  `(θ) = −Eµ log µ̄+(x) + λ− ∫ M µ̄−dV + λ+ ∫ M µ̄+dV (16)
  with λ− + λ+ ≥ 1. Empirically we found this loss favorable in some cases (i.e., with λ+ > 0).
  Integral approximation. The integral ∫ M µ̄−dV in the losses in equation 16 and 14 is approximated by considering a set Y = {yj}lj=1 of i.i.d. samples according to some distribution η overM and taking a Monte Carlo estimate ∫
  M µ̄−dV ≈
  1
  l l∑ j=1 µ̄−(yj) η(yj) . (17)
  ∫ M µ̄+dV is approximated similarly. In this paper we opted for the simple choice of taking η to be the uniform distribution overM.
sections.heading: 4 Generative modeling over Euclidean submanifolds
sections.text: In this section, we adapt the Moser Flow (MF) generative model to submanifolds of Euclidean spaces. That is we consider an orientable, compact, boundaryless, connected n-dimensional submanifold M⊂ Rd, where n < d. Examples include implicit surfaces and manifolds (i.e., preimage of a regular value of a smooth function), as well as triangulated surfaces and manifold simplicial complexes. We
  denote points in Rd (and therefore inM) with x,y ∈ Rd. As the Riemannian metric ofM we take the induced metric from Rd; that is given arbitrary tangent vectors v,u ∈ TxM the metric is defined by 〈v,u〉g = 〈v,u〉, where the latter is the Euclidean inner product. We denote by π : Rd →M the closest point projection onM, i.e., π(x) = miny∈M ‖x− y‖, with ‖y‖2 = 〈y,y〉 the Euclidean norm in Rd. Lastly, we denote by Px ∈ Rd×d the orthogonal projection matrix on the tangent space TxM; in practice if we denote by N ∈ Rd×k the matrix with orthonormal columns spanning NxM = (TxM)⊥ (i.e., the normal space toM at x) then, Px = I −NNT . We parametrize the vector field u required for our MF model (in equation 12) by defining a vector field u ∈ X(Rd) such that u|M ∈ X(M). We define
  u(x) = Pπ(x)vθ(π(x)), (18)
  where vθ : Rd → Rd is an MLP with Softplus activation (β = 100) and learnable parameters θ ∈ Rp. By construction, for x ∈M, u(x) ∈ TxM. To realize the generative model, we need to compute the divergence div(u(x)) for x ∈ M with respect to the Riemannian manifoldM and metric g. The vector field u in equation 18 is constant along normal directions to the manifold at x (since π(x) is constant in normal directions). If n ∈ NxM, then in particular
  d
  dt ∣∣∣ t=0 u(x + tn) = 0. (19)
  We call vector fields that satisfy equation 19 infinitesimally constant in the normal direction. As we show next, such vector fields u ∈ X(M) have the useful property that their divergence along the manifoldM coincides with their Euclidean divergence in the ambient space Rd: Lemma 2. If u ∈ X(Rd), u|M ∈ X(M) is infinitesimally constant in normal directions ofM, then for x ∈M, div(u(x)) = divE(u(x)), where divE denotes the standard Euclidean divergence.
  This lemma simply means we can compute the Euclidean divergence of u in our implementation. Given a set of observed data X = {xi}mi=1 ⊂ M ⊂ Rd, and a set of uniform i.i.d. samples Y = {yj}lj=1 ⊂M overM, our loss (equation 14) takes the form
  `(θ) = − 1 m m∑ i=1 log max { , ν(xi)− divEu(xi)}+ λ′− l l∑ j=1 ( −min { , ν(yj)− divEu(yj)} ) ,
  where λ′− = λ−V (M). We note the volume constant can be ignored by considering an un-normalized source density V (M)ν ≡ 1, see supplementary for details. The loss in equation 16 is implemented similarly, namely, we add the empirical approximation of λ+ ∫ M µ̄+dV .
  We conclude this section by stating that the MF generative model over Euclidean submanifolds (defined with equations 12 and 18) is universal. That is, MFs can generate, arbitrarily well, any continuous target density µ on a submanifold manifoldM⊂ Rd. Theorem 3. Given an orientable, compact, boundaryless, connected, differentiable n-dimensional submanifoldM ⊂ Rd, n < d, and a target continuous probability density µ : M → R>0, there exists for each > 0 an MLP vθ and a choice of weights θ so that µ̄ defined by equations 12 and 18 satisfies
  max x∈M
  |µ(x)− µ̄(x)| < .
sections.heading: 5 Experiments
sections.text: In all experiments, we modeled a manifold vector field as a multi-layer perceptron (MLP) uθ ∈ X(M), with parameters θ. All models were trained using Adam optimizer (Kingma and Ba, 2014), and in all neural networks the activation is Softplus with β = 100. Unless stated otherwise, we set λ+ = 0. We used an exact calculation of the divergence divE(u(x)). We experimented with two kinds of manifolds.
  Flat Torus. To test our method on Euclidean 2D data, we usedM as the flat torus, that is the unit square [−1, 1]2 with opposite edges identified. This defines a manifold with no boundary which is locally isometric to the Euclidean plane. Due to this local isometry the Riemannian divergence on the flat
  torus is equivalent to the Euclidean divergence, div = divE . To make uθ a well defined smooth vector field inM we use periodic positional encoding, namely uθ(x) = vθ(τ(x)), where vθ is a standard MLP and τ : R2 → R4k is defined as τ(x) = (cos(ω1πx), sin(ω1πx), ..., cos(ωkπx), sin(ωkπx)), where wi = i, and k is a hyper-parameter that is application dependent. Since any periodic function can be approximated by a polynomial acting on eiπx, even for k = 1 this is a universal model for continuous functions on the torus. As described by Tancik et al. (2020), adding extra features can help with learning higher frequencies in the data. To solve an ODE on the torus we simply solve it for the periodic function and wrap the result back to [−1, 1]2. Implicit surfaces. We experiment with surfaces as submanifolds of R3. We represent a surface as the zero level set of a Signed Distance Function (SDF) f : R3 → R. We experimented with two surfaces. First, the sphere, represented with the SDF f(x) = ‖x‖ − 1, and second, the Stanford Bunny surface, representing a general curved surface and represented with an SDF learned with (Gropp et al., 2020) from point cloud data. To model vector fields on an implicit surface we follow the general equation 18, where for SDFs
  π(x) = x− f(x)∇f(x), and Px = I −∇f(x)∇f(x)T .
  In the supplementary, we detail how to replace the global projection π(x) with a local one, for cases the SDF is not exact.
sections.heading: 5.1 Toy distributions
sections.text: First, we consider a collection of challenging toy 2D datasets explored in prior works (Chen et al., 2020; Huang et al., 2021). We scale samples to lie in the flat torus [−1, 1]2 and use k = 1 for the positional encoding. Figure 2 depicts the input data samples, the generated samples after training, and the learned distribution µ̄. In the top six datasets, the MLP architecture used for Moser Flows consists of 3 hidden layers with 256 units each, whereas in the bottom two we used 4 hidden layers with 256 neurons due to the higher complexity of these distributions. We set λ− = 2.
sections.heading: 5.2 Choice of hyper-parameter λ
sections.text: We test the effect of the hyper-parameter λ ≥ 1 on the learned density. Figure 3 shows, for different values of λ, our density estimation µ+, the push-forward density Φ∗ν, and their absolute difference. To evaluate Φ∗ν from the vector field vt, we solve an ODE as advised in Grathwohl et al. (2018).
  As expected, higher values of λ lead to closer modeled density µ̄+ and Φ∗ν. This is due to the fact that a higher value of λ leads to a lower value of ∫ M µ̄−, meaning µ̄ is a better representation of a probability density. Nonetheless, even for λ = 1 the learned and generated density are rather consistent.
sections.heading: 5.3 Time evaluations
sections.text: To compare our method to Euclidean CNF methods, we compare Moser Flow with FFJORD (Grathwohl et al., 2018) on the flat torus. We consider a challenging density with high frequencies obtained via 800x600 images (Figure 4). We generate a new batch every iteration by sampling each pixel location with probability which is proportional to the pixel intensity. The architectures of both vθ and the vector field defined in FFJORD are the same, namely an MLP with 4 hidden layers of 256 neurons each. To capture the higher frequencies in the image we use a positional encoding with k = 8 for both methods. We used a batch size of 10k. We used learning rate of 1e-5 for Moser Flow and 1e-4 for FFJORD. We used λ− = 2. Learning was stopped after 5k seconds. Figure 4 presents the results. Note that Moser Flow captures high-frequency details better than FFJORD. This is also expressed in the graph on the top right, showing how the NLL decreases faster for MF than FFJORD. Furthermore, as can be inspected in the per iteration time graph on the bottom-right, MF per iteration time does not increase during training, and is roughly 1-2 order of magnitudes faster than FFJORD iteration.
sections.heading: 5.4 Earth and climate science data
sections.text: We evaluate our model on the earth and climate datasets gathered in Mathieu and Nickel (2020). The projection operator π in this case is simply π(x) = x‖x‖ . We parameterize vθ as an MLP with 6 hidden layers of 512 neurons each. We used full batches for the NLL loss and batches of size 150k for our integral approximation. We trained for 30k epochs, with learning rate of 1e-4. We used λ− = 100. The quantitative NLL results are reported in Table 1 and qualitative visualizations in 5. Note that we produce NLL scores smaller than the runner-up method by a large margin.
sections.heading: 5.5 Curved surfaces
sections.text: We trained an SDF f for the Stanford Bunny surfaceM using the method in Gropp et al. (2020). To generate uniform (ν) and data (µ) samples overM we first extract a meshM′ from f using the Marching Cubes algorithm (Lorensen and Cline, 1987) setting its resolution to 100x100x100. Then, to randomly choose a point uniformly fromM′ we first randomly choose a face of the mesh with probability proportional to its area, and then randomly choose a point uniformly within that face. For target µ we used clamped manifold harmonics to create a sequence of densities with increased complexity. To that end, we first computed the k-th eigenfunction of the Laplace-Beltrami operator overM′ (we provide details on this computation in the supplementary), for the frequencies (eigenvalues) k ∈ {10, 50, 500}. Next, we sampled the eigenfunctions at the faces’ centers, clamped their negative values, and normalized to get discrete probability densities over the faces ofM′. Then, to sample a point, we first choose a face at random based on this probability, and then random a point uniformly within that face. We take 500k i.i.d. samples of this distribution as our dataset. We take vθ to be an MLP with 6 hidden layers of dimension 512. We use batch size of 10k for both the NLL loss and for the integral approximation; we ran for 1000 epochs with learning rate of 1e-4. We used λ− = λ+ = 1. Figure 6 depict the results. Note that Moser Flow is able to learn the surface densities for all three frequencies.
sections.heading: 6 Related Work
sections.text: In the following, we discuss related work on normalizing flows for manifold-valued data. On a high level, such methods can be divided into Parametric versus Riemannian methods. Parametric methods consist of a normalizing flow in the Euclidean space Rn, pushed-forward onto the manifold through an invertible map ψ : Rn → M. However, to globally represent the manifold, ψ needs to be a homeomorphism implying thatM and Rn are topologically equivalent, limiting the scope of that
  approach. Existing methods in this class are often based on the exponential map expx : TxM ∼= Rn → M of a manifold. This leads to the so called wrapped distributions. This approach has been taken, for instance, by Falorsi et al. (2019) and Bose et al. (2020) to parametrize probability distributions on Lie groups and hyperbolic space. However, Parametric methods based on the exponential map often lead to numerical and computational challenges. For instance, in compact manifolds (e.g., spheres or the SO(3) group) computing the density of wrapped distributions requires an infinite summation. On the hyperboloid, on the other hand, the exponential map is numerically not well-behaved far away from the origin (Dooley and Wildberger, 1993; Al-Mohy and Higham, 2010).
  In contrast to Parametric methods, Riemannian methods operate directly on the manifold itself and, as such, avoid numerical instabilities that arise from the mapping onto the manifold. Early work in this class of models proposed transformations along geodesics on the hypersphere by evaluating the exponential map at the gradient of a scalar manifold function (Sei, 2011). Rezende et al. (2020) introduced discrete Riemannian flows for hyperspheres and torii based on Möbius transformations and spherical splines. Mathieu and Nickel (2020) introduced continuous flows on general Riemannian manifolds (RCNF). In contrast to discrete flows (e.g., Bose et al., 2020; Rezende et al., 2020), such time-continuous flows alleviate the previous topological constraints by parametrizing the flow as the solution to an ODE over the manifold (Grathwohl et al., 2018). Concurrently to RCNF, Lou et al. (2020) and Falorsi and Forré (2020) proposed related extensions of neural ODEs to smooth manifolds. Moser Flow also generates a CNF, however by limiting the flow space (albeit, not the generated distributions) it allows expressing the learned distribution as the divergence of a vector field.
sections.heading: 7 Discussion and limitations
sections.text: We introduced Moser Flow, a generative model in the family of CNFs that represents the target density using the divergence operator applied to a vector valued neural network. The main benefits of MF stems from the simplicity and locality of the divergence operator. MFs circumvent the need to solve an ODE in the training process, and are thus applicable on a broad class of manifolds. Theoretically, we prove MF is a universal generative model, able to (approximately) generate arbitrary positive target densities from arbitrary positive prior densities. Empirically, we show MF enjoys favorable computational speed in comparison to previous CNF models, improves density estimation on spherical data compared to previous work by a large margin, and for the first time facilitate training a CNF over a general curved surface.
  One important future work direction, and a current limitation, is scaling of MF to higher dimensions. This challenge can be roughly broken to three parts: First, the model probabilities µ̄ should be computed/approximated in log-scale, as probabilities are expected to decrease exponentially with the dimension. Second, the variance of the numerical approximations of the integral ∫ M µ̄−dV will increase significantly in high dimensions and needs to be controlled. Third, the divergence term, div(u), is too costly to be computed exactly in high dimensions and needs to be approximated, similarly to other CNF approaches. Finally, our work suggests a novel generative model, and similarly to other generative models can be potentially used for generation of fake data and amplify harmful biases in the dataset. Mitigating such harms is an active and important area of ongoing research.
sections.heading: Acknowledgments
sections.text: NR is supported by the European Research Council (ERC Consolidator Grant, "LiftMatch" 771136), the Israel Science Foundation (Grant No. 1830/17), and Carolito Stiftung (WAIC).
title: Moser Flow: Divergence-based Generative Modeling on Manifolds