Title: CONTINUOUS-TIME FLOWS FOR EFFICIENT INFER-ENCE AND DENSITY ESTIMATION Anonymous

Abstract: Two fundamental problems in unsupervised learning are efficient inference for latent-variable models and robust density estimation based on large amounts of unlabeled data. For efficient inference, normalizing flows have been recently developed to approximate a target distribution arbitrarily well. In practice, however, normalizing flows only consist of a finite number of deterministic transformations, and thus they possess no guarantee on the approximation accuracy. For density estimation, the generative adversarial network (GAN) has been advanced as an appealing model, due to its often excellent performance in generating samples. In this paper, we propose the concept of continuous-time flows (CTFs), a family of diffusion-based methods that are able to asymptotically approach a target distribution. Distinct from normalizing flows and GANs, CTFs can be adopted to achieve the above two goals in one framework, with theoretical guarantees. Our framework includes distilling knowledge from a CTF for efficient inference, and learning an explicit energy-based distribution with CTFs for density estimation. Experiments on various tasks demonstrate promising performance of the proposed CTF framework, compared to related techniques. * Although the density is represented as an energy-based distribution with an intractable normalizer.

1. INTRODUCTION:

Efficient inference and robust density estimation are two important goals in unsupervised learning. In fact, inference and density estimation can be unified from the perspective of learning desired target distributions. In inference problems, one is given an unnormalized distribution (e.g., the posterior distribution), and the goal is to learn a distribution that is close to the unnormalized distribution. In density estimation, one tries to learn an unknown data distribution given samples from it. It is also helpful to make a distinction between two types of representations for learning distributions: explicit and implicit methods (Mohamed & Lakshminarayanan, 2017) . Explicit methods provide a prescribed parametric form for the distribution, while implicit methods learn a stochastic procedure to directly generate samples from the unknown distribution.

Existing deep generative models can easily be identified from this taxonomy. For example, the standard variational autoencoder (VAE) (Kingma & Welling, 2014; Rezende et al., 2014) is an important example of an explicit inference method. Within the inference arm (encoder) of a VAE, recent research has focused on improving the accuracy of the approximation to the posterior distribution on latent variables (codes) using normalizing flow (Rezende & Mohamed, 2015) . Normalizing flow is particularly interesting due to its ability to approximate the posterior distribution arbitrarily well, while maintaining explicit parametric forms. On the other hand, Stein VAE (Feng et al., 2017; Pu et al., 2017b ) is an implicit inference method, as it only learns to draw samples to approximate posteriors, without assuming an explicit form for the distribution.. For density estimation on observed data, the generative adversarial network (GAN) can be regarded as an implicit density estimation method (Ranganath et al., 2016; Huszár, 2017; Mohamed & Lakshminarayanan, 2017) , in the sense that one may sample from the distribution (regarded as a representation of the unknown distribution), but an explicit form for the distribution is not estimated. GAN has recently been augmented by Flow-GAN (Grover et al., 2017) to incorporate a likelihood term for explicit density estimation. Further, there also are some works trying to perform inference within the implicit density estimation framework, e.g., the real-valued non-volume preserving (real NVP) transformations algorithm (Dinh et al., 2017) was proposed as a tractable yet expressive approach to model high-dimensional data. Some aforementioned methods rely on the concept of flows. A flow defines a series of transformations for a random variable (RV), such that the distribution of the RV evolves from a simple distribution to a more complex distribution. When the sequence of transformations are indexed on a discrete-time domain (e.g., indexed with integers) with a finite number of transformations, this method is referred to as a normalizing flow (Rezende & Mohamed, 2015) . Various efficient implementations of normalizing flows have been proposed, such as the planar, radial (Rezende & Mohamed, 2015) , Householder (Tomczak & Welling, 2016) , and inverse autoregressive flows (Kingma et al., 2016) . One theoretical limitation of existing normalizing flows is that there is no guarantee on the approximation accuracy due to the finite number of transformations.

By contrast, little work has explored the applicability of continuous-time flows (CTFs) in deep generative models, where a sequence of transformations are indexed on a continuous-time domain (e.g., indexed with real numbers). There are at least two reasons encouraging research in this direction: i) CTFs are more general than traditional normalizing flows in terms of modeling flexibility, due to the intrinsic infinite number of transformations; ii) CTFs are more theoretically grounded, in the sense that they are guaranteed to approach a target distribution asymptotically (details provided in Section 2.2). Unfortunately, these advantages also bring challenges for efficient learning, in that: i) it is difficult to optimize over the variational lower bound in the inference framework, due to the extra randomness introduced in CTFs; ii) it is difficult to design algorithms for efficient learning of CTF-based models, due to the induced infinite number of transformations.

In this paper, we propose efficient ways to apply CTFs for the two motivating tasks. Based on the CTF, our framework learns to drawn samples directly from desired distributions (e.g., the unknown posterior and data distributions) for both inference and density estimation tasks. In addition, we are able to learn an explicit form of the unknown data distribution for density estimation * . This shares a similar flavor as Wang & Liu (2017) ; Feng et al. (2017) . Specifically, i) for efficient inference, we first show that optimizing the variational lower bound with CTFs can be achieved by decomposing the optimization problem into a sequence of sub-optimization problems, based on a variational formulation of the Fokker-Planck equations from statistical physics (Jordan et al., 1998) . Based on this decomposition, we derive bounds on the approximation errors when applying numerical methods to solve a CTF. For computational efficiency, we generalize ideas from Gershman & Goodman (2014) to distill knowledge of a CTF into an efficient inference network; ii) for density estimation, we propose to use a flexible Gibbsian-style distribution (implemented by a deep neural network) to model an unknown data distribution, whose samples can be drawn by learning a stochastic generator with our CTF framework. The Gibbsian-style data distribution and the stochastic generator are learned alternatively, leading to a learning procedure that is connected to the GAN framework (Goodfellow et al., 2014) , but that yields an explicit distribution for the data. We conduct a number of experiments on real datasets, demonstrating excellent performance of the proposed framework, relative to existing representative approaches.

2. PRELIMINARIES:

We first review related techniques of performing efficient inference and density estimation in the machine learning literature. We then introduce the general concept of continuous-time flows.

2.1. EFFICIENT INFERENCE AND DENSITY ESTIMATION:

Efficient inference with normalizing flows Consider a probabilistic generative model with observation x ∈ R D and latent variable z ∈ R L such that x | z ∼ p θ (x | z) with z ∼ p(z). For efficient inference of z, the VAE (Kingma & Welling, 2014) introduces the concept of an inference network (recognition model or encoder), q φ φ φ (z | x), as a variational distribution in the VB framework. An inference network is typically a stochastic (nonlinear) mapping from the input x to the latent z, with associated parameters φ φ φ. For example, one of the simplest inference networks is defined as

q φ φ φ (z | x) = N (z; µ φ φ φ (x), diag(σ 2 φ φ φ (x)))

, where the mean function µ φ φ φ (x) and the standardderivation function σ φ φ φ (x) are specified via deep neural networks parameterized by φ φ φ. Parameters are learned by minimizing the evidence lower bound (ELBO), i.e., the KL divergence between p θ (x, z)

and q φ φ φ (z | x): KL (q φ φ φ (z | x) p θ (x, z)) E q φ φ φ (z | x) [log q φ φ φ (z | x) -log p θ (x, z)],

via stochastic gradient descent (Bottou, 2012) .

One limitation of the VAE framework is that q φ φ φ (z | x) is often restricted to simple distributions for feasibility, e.g., the normal distribution discussed above, and thus the gap between q φ φ φ (z | x) and p θ (z | x) is typically large for complicated posterior distributions. Normalizing flows is a recently proposed VB-based technique designed to mitigate this problem (Rezende & Mohamed, 2015) . The idea is to augment z via a sequence of deterministic invertible transformations {T k : R L → R L } K k=1 , such that:

z 0 ∼ q φ φ φ (•| x), z 1 = T 1 (z 0 ), • • • , z K = T K (z K-1 ).

Note the transformations {T k } are typically endowed with different parameters, and we absorb them into φ φ φ. Because the transformations are deterministic, the distribution of z K can be written as

q(z K ) = q φ φ φ (z 0 | x) K k=1 det ∂T k ∂ z k -1

via the change of variable formula. As a result, the ELBO for normalizing flows becomes:

KL (q φ φ φ (z K | x) p θ (x, z)) =

(1)

E q φ φ φ (z0 | x) [log q φ φ φ (z 0 | x)] -E q φ φ φ (z0 | x) [log p θ (x, z K )] -E q φ φ φ (z0 | x) K k=1 log det ∂T k ∂ z k .

Typically, transformations T k of a simple parametric form are employed to make the computations tractable (Rezende & Mohamed, 2015) . Our method for inference generalizes these discrete-time transformation to continuous-time transformations, ensuring convergence of the transformations to the target distribution.

Density estimation overview There exist implicit and explicit density-estimation methods. Implicit density models such as GAN provide a flexible way to draw samples directly from unknown data distributions (via a deep neural network (DNN) called a generator with stochastic inputs) without explicitly modeling their density forms; whereas explicit models such as the pixel RNN/CNN (van den Oord et al., 2016) define and learn explicit forms of the unknown data distributions. This gives the advantage that the likelihood for a test data point can be explicitly evaluated. However, the generation of samples is typically time-consuming due to the sequential generation nature.

Similar to Wang & Liu (2017) , our CTF-based approach in Section 4 provides an alternative way for this problem, by simultaneously learning an explicit Gibbsian-style data distribution (estimated density) and a generator whose generated samples match the learned Gibbsian distribution. This not only gives us the advantage of explicit density modeling but also provides an efficient way to generate samples.

2.2. CONTINUOUS-TIME FLOWS:

We notice two potential limitations with traditional normalizing flows: i) given specified transformations {T k }, there is no guarantee that the distribution of z K could exactly match p θ (x, z); ii) the randomness is only introduced in z 0 (from the inference network), limiting the representation power. We specify CTFs where the transformations are indexed by real numbers, thus they could be considered as consisting of an infinite number of transformations. Further, we consider stochastic flows where randomness is injected in a continuous-time manner. In fact, the concept of CTFs (such as the Hamiltonian flow) has been introduced in Rezende & Mohamed (2015) , without further development on efficient inference.

We consider a flow on R L , defined as the mapping † T : R L × R → R L such that ‡ we have T (Z, 0) = z and T (T (Z, t), s) = T (Z, s + t), for all Z ∈ R L and s, t ∈ R. A typical example of this family is defined as T (Z, t) = Z t , where Z t is driven by a diffusion of the form:

EQUATION

Here F : R L → R L , V : R L×L → R L are called the drift term and diffusion term, respectively; W is the standard L-dimensional Brownian motion. In the context of inference, we seek to make the stationary distribution of Z t approach p θ (z | x). One solution for this is to set

F (Z t ) = 1 2 ∇ z log p θ (x, z = Z t ) and V (Z t ) = I L with I L the L × L identity matrix.

The resulting diffusion is called Langevin dynamics Welling & Teh (2011) . Denoting the distribution of Z t as ρ t , it is well known Risken (1989) that ρ t is characterized by the Fokker-Planck (FP) equation:

EQUATION

where a • b a b for vectors a and b, A : B trace(A B) for matrices A and B.

For simplicity, we consider the flow defined by the Langevin dynamics specified above, though our results generalize to other stochastic flows Dorogovtsev & Nishchenko (2014) . In the following, we specify the ELBO under a CTF, which can then be readily solved by a discretized numerical scheme, based on the results from Jordan et al. (1998) . An approximation error bound for the scheme is also derived. We defer proofs of our theoretical results to the Supplementary Material (SM) for conciseness.

3. CONTINUOUS-TIME FLOWS FOR INFERENCE:

We first give an overview of our CTF-based method for efficient inference. We adopt the VAE/normalizing-flow framework with an encoder-decoder structure. An important difference is that instead of feeding data to an encoder and sampling a latent representation in the output as in VAE, we concatenate the data with independent noise as input and directly generate output samples § . These output samples are then driven by the CTF to approach the true posterior distribution. In the learning process, the implicit transformations from the CTF are sequentially distilled into the inference network by amortized learning, making the inference network flexible enough to represent the true posterior distribution. In the following subsections, we specify our framework in detail.

3.1. THE VARIATIONAL LOWER BOUND AND DISCRETIZED APPROXIMATION:

We first incorporate CTF into the normalizing-flow framework by writing out the corresponding ELBO. Note that there are two steps in the inference process. First, an initial z 0 is drawn from the inference network q φ φ φ (•| x); second, z 0 is evolved via a diffusion such as (2) for time T (via the transformation Z T = T (z 0 , T )). Consequently, the ELBO for CTF can be written as

F(x) = E q φ φ φ (z0 | x) E ρ T log ρ T -log p θ (x, Z T ) + log det ∂ Z T ∂ z 0 E q φ φ φ (z0 | x) [F 1 (x, z 0 )] . (4)

Note the term F 1 (x, z 0 ) is intractable to calculate, in that i) ρ T does not have an explicit form; ii) the Jacobian ∂ Z T ∂ z0 is generally infeasible. In the following, we propose an approximate solution for problem i). Learning by avoiding problem ii) is presented in Section 3.2 via amortization.

For problem i), a reformulation of the results from Jordan et al. (1998) leads to a nice way to approximate ρ t in Lemma 1. Note in practice we adopt an implicit method which uses samples to approximate the solution in Lemma 1 for feasibility, detailed in (6). Lemma 1. Assume that log p θ (x, z) ≤ C 1 is infinitely differentiable, and

∇ z log p θ (x, z) ≤ C 2 (1 + C 1 -log p θ (x, z)) (∀ x, z) for some constants {C 1 , C 2 }. Let T = hK (h is

the stepsize in discretization and K is the number of transformations), ρ 0 q φ φ φ (z 0 | x), and {ρ k } K k=1 be the solution of the functional optimization problem:

EQUATION

where

W 2 2 (µ 1 , µ 2 ) inf p∈P(µ1,µ2) x -y 2 2 p(d x, d y), W 2 (µ 1 , µ 2 )

is the 2nd-order Wasserstein distance, with P(µ 1 , µ 2 ) being the space of joint distributions on {µ 1 , µ 2 }. K is the space of probability distributions with the finite 2nd-order moment. Then ρK converges to ρ T in the limit of h → 0, i.e., lim h→0 ρK = ρ T , where ρ T is the solution of the FP equation (3) at time T .

Lemma 1 reveals an interesting way to compute ρ T via a sequence of functional optimization problems. By comparing it with the objective of the traditional normalizing flow, which minimizes the KL-divergence between ρ K and p θ (x, z), at each sub-optimization-problem in Lemma 1, it minimizes the KL-divergence between ρk and p θ (x, z), plus a regularization term as the Wasserstein distance between ρk-1 and ρk . The extra Wasserstein-distance term arises naturally due to the fact that the Langevin diffusion can be explained as a gradient flow whose geometry is equipped with the Wasserstein distance (Otto, 1998) . From another point of view, it is known that the Wasserstein distance is a better metric for probability distributions than the KL-divergence, especially in the case of non-overlapping domains (Arjovsky & Bottou, 2017; Arjovsky et al., 2017) . By using the Wasserstein term as a regularizer, the CTF alleviates the issue in non-overlapping domains by introducing the Brownian-motion (noise) term in the evolution (2). This relates to the idea in (Arjovsky & Bottou, 2017) , in which noise is added in parameter updates to alleviate the intrinsic drawback of the KL-divergence metric.

The optimization problem in Lemma 1 is difficult to deal with directly. In practice, we instead approximate the discretization in an equivalent way by simulation from the CTF. Starting from z 0 ,

z k (k = 0, • • • , K -1

) is fed into a transformation T k (specified below), resulting in z k+1 whose distribution coincides with ρk+1 in Lemma 1. The discretization procedure is illustrated in Figure 1 . We must specify the transformations T k . For each k, let t = hk; we can conclude from Lemma 1 that lim h→0 ρk = ρ t . From FP theory, ρ t is obtained by solving the diffusion (2) with initial condition Z 0 = z 0 . It is thus reasonable to specify the transformation T k as the k-th step of a numerical integrator for (2). Specifically, we specify T k as a stochastic transformation:

EQUATION

where ζ k ∼ N (0, hI L ) is drawn from an isotropic normal. Note the transformation defined here is stochastic, thus we only get samples from ρK at the end. A natural way to approximate ρK is to use the empirical sample distribution, i.e., ρK ≈ 1 K K k=1 δ z k ρT with δ z a point mass at z. Afterwards, ρK (thus ρT ) will be used to approximate the true ρ T from (3). Inference network Generative model Note that we use the simple sample averaging for the convenience of analysis, and the approximation for ρ T is not necessarily optimal. Better approximation can be obtained by assigning more weights to the more recent samples. However, this leads to more challenges in theoretical analysis, an interesting future direction to pursue. In the following, we study how well ρT approximates ρ T . Following literature on numerical approximation for Itô diffusions (Vollmer et al., 2016; Chen et al., 2015) , we consider a 1-Lipschitz test function ψ : R L → R, and use the mean square error (MSE) bound to measure the closeness of ρT and ρ T , defined as:

⋯ ⋯ ⋯ ⋯ ⋯ Z 0 Z T z 0 z 1 z 2 z K 1 z K T 1 T 2 T K 1

MSE(ρ T , ρ T ; ψ) E ψ(z)(ρ T -ρ T )(z)d z 2 ,

where the expectation is taken over all the randomness in the construction of ρT . Note that our goal is related but different from the standard setup as in Vollmer et al. (2016) ; Chen et al. (2015) , which studies the closeness of ρT to p θ (x, z). We need to adopt the assumptions from Vollmer et al. (2016) ; Chen et al. (2015) , which are described in the Supplementary Material (SM). The assumptions are somewhat involved but essentially require coefficients of the diffusion (2) to be well-behaved. We derive the following bound for the MSE of the sampled approximation, ρT , and the true distribution.

Theorem 2. Under Assumption 1 in the SM, assume that ρ T (z)p -1 θ (x, z)d z < ∞ and there exists a constant C such that

dW 2 2 (ρ T ,p θ (x,z)) dt ≥ CW 2 2 (ρ T , p θ (x, z)), the MSE is bounded as MSE(ρ T , ρ T ; ψ) = O 1 hK + h 2 + e -2ChK .

The last assumption in Theorem 2 requires ρ T to evolve fast through the FP equation, which is a standard assumption used to establish convergence to equilibrium for FP equations (Bolley et al., 2012) . The MSE bound consists of three terms, the first two terms come from numerical approximation of the continuous-time diffusion, whereas the third term comes from the convergence bound of the FP equation in terms of the Wasserstein distance (Bolley et al., 2012) . When the time T = hK is large enough, the third term may be ignored due to its exponential-decay rate. Moreover, in the infinite-time limit, the bound endows a bias proportional to h; this, however, can be removed by adopting a decreasing-step-size scheme in the numerical method, as in standard stochastic gradient MCMC methods (Teh et al., 2016; Chen et al., 2015) . Remark 3. To examine the optimal bound in Theorem 2, we drop out the term e -2ChK in the long-time case (when hK is large enough) for simplicity because it is in a much lower order term than the other terms. The optimal MSE bound (over h) decreases at a rate of O K -2/3 , meaning that O -3/2 steps of transformations in Figure 1 (right) are needed to reach an -accurate approximation, i.e., MSE ≤ . This is computationally expensive. An efficient way for inference is thus imperative, developed in the next section.

3.2. EFFICIENT INFERENCE VIA AMORTIZATION:

Even though we approximate ρ T with ρT , it is still infeasible to directly apply it to the ELBO in (4) as ρT is discrete. To deal with this problem, we adopt the idea of "amortized learning" (Gershman & Goodman, 2014) for efficient inference. The main idea is to optimize the two sets of parameters φ φ φ and θ alternatively, based on different but related objective functions.

Updating φ φ φ To explain the idea, first note that the ELBO can be equivalently written as

EQUATION

When ρ 0 = ρ T , it is easy to see that:

F(x) = E ρ0 [log ρ 0 -log p θ (Z T | x)] + log p(x) = log p(x),

which essentially makes the gap between q φ φ φ (z 0 | x) and p θ (Z T | x) vanished. As a result, our goal is to learn φ φ φ such that q φ φ φ (z 0 | x) approaches p θ (Z T | x). As mentioned previously, we will learn an implicit distribution of q φ φ φ (z 0 | x) (i.e., learn how to draw samples from q φ φ φ (z 0 | x) instead of its explicit form), as it allows us to chose a candidate distribution from a much larger distribution space, compared to explicitly defining q φ φ φ ¶ . Consequently, q φ φ φ (z 0 | x) is implemented by a stochastic generator (a DNN parameterized by φ φ φ) Q φ φ φ (z 0 | x, ω) with input as the concatenation of x and ω, where ω is a sample from an isotropic Gaussian distribution q 0 (ω). Our goal is now translated to update the parameter φ φ φ of Q φ φ φ (z 0 | x, ω) to φ φ φ such that the distribution of {z 0 = Q φ φ φ (z 0 | x, ω)} with ω ∼ q 0 (ω) matches that of z 1 in the original generating process with φ φ φ in Figure 1 . In this way, the generating process of z 1 via T 1 is distilled into the parameterized generator Q φ φ φ (•), eliminating the need to do a specific transformation via T 1 in testing, and thus is very efficient. Specifically, we update φ φ φ such that

EQUATION

where {z (i) 0 } S i=1 are a set of samples generated from q φ φ φ (z 0 | x) via Q φ (•), and {z

(i) 1 } S i=1 are samples drawn by ω i ∼ q 0 (ω), zi 0 = Q φ φ φ (•| x, ω i ), z (i) 1 ∼ T 1 (z i 0 ); D(•, •

) is a metric between samples such as the simple Euclidean distance or the more advanced Wasserstein distance (Arjovsky et al., 2017) . The optimization is done by applying standard stochastic gradient descent (SGD). We call this procedure distilling knowledge from T 1 to Q φ φ φ (•).

After distilling knowledge from T 1 , we apply the same procedure for other transformations T k (k > 1) sequentially. The final inference network, represented by q φ φ φ (•| x), can then well approximate the continuous-time flows, e.g., the distribution of z 0 ∼ q φ φ φ (•| x) is close to ρ T from the CTF. This concept is illustrated in Figure 2 . According to Theorem 2, the number of updates for φ φ φ in training is still bounded by O( -3/2 ) for an -accurate MSE, however, inference in testing is significantly boosted since we do not need to simulate a long-time transformations as shown in Figure 1 (right).

Updating θ Given φ φ φ, θ can be updated by simply optimizing the ELBO in (7), where ρ T is approximated by ρT from the discretized CTF. Specifically, the expectation w.r.t. ρ T in ( 7) is approximated by a sample average from:

z 0 ∼ q φ φ φ (z 0 | x), z 1 ∼ T 1 (z 0 ), z 2 ∼ T 2 (z 1 ), • • • , z K ∼ T K (z K-1 ) . ! " ($ % |') ⋯ * + ('|$) $ % ⋯ step 1 step K ! " ($ % |') ⋯ * + ('|$) $ , $ % ⋯ $ -$ . ⋯ ⋯ ⋮ ! " ($ % |') ⋯ * + ('|$) $ , $ % ⋯ $ .

⋯ ⋮:

Figure 2 : Amortized learning of continuous-time flows for VAEs. From left to right: the initial architecture with K-step transformations; For each step k, q φ φ φ (•) is trained to match the distributin of z k in CTFs; In the end, the CTF is distilled into q φ φ φ (•).

To sum up, there are three main steps in learning a CTF-based VAE:

1. Generate a sample path (z 0 , • • • , z K ) according to q φ φ φ (z 0 | x) and the discretized flow with transformations {T k }; 2. Update φ φ φ according to (8); 3. Optimize θ by minimizing the ELBO (7) with the generated sample path.

In testing, we use only the finally learned q φ φ φ (z 0 | x) for inference (into which the CTF has been distilled), and hence testing is like the standard VAE. Since the discretized-CTF model is essentially a Markov chain, we call our model Markov-chain-based VAE (MacVAE).

4. CONTINUOUS TIME FLOWS FOR EXPLICIT DENSITY ESTIMATION:

We describe how to apply the proposed CTF framework to density estimation of the observed data. We assume that the density of the observation x is characterized by a parametric Gibbsian-style probability model p θ (x;θ) , where pθ (x) is an unnormalized version of p θ (x) with parameter θ, U (x; θ) log pθ (x) is called the energy function (Zhao et al., 2017) , and Z(θ) pθ (x)d x is the normalizer. Note this form of distributions constitutes a very large class of distributions as long as the capacity of the energy function is large enough. This can be easily achieved by adopting a DNN to implement U (x; θ), the setting we considered in this paper. Note our model can be placed in between existing implicit and explicit density estimation methods, because we model the data density with an explicit distribution form up to an intractable normalizer. Such distributions have been proved to be useful in real applications, e.g., Haarnoja et al. (2017) used them to model policies in deep reinforcement learning.

(x) = 1 Z(θ) pθ (x) 1 Z(θ) e U

Our goal is to learn θ given observations {x i } N i=1 , which can be achieved via the standard maximum likelihood estimator (MLE):

θ = arg max θ N i=1 log p θ (x i ) arg max θ M({x i }; θ)

This is usually optimized via SGD, with the following gradient formula:

∂M({x i }; θ) ∂θ = 1 N N i=1 ∂U (x i ; θ) ∂θ -E p θ (x) ∂U (x; θ) ∂θ (9)

Algorithm 1 CTFs for generative models at the k-th iteration. D(•, •) is the same as (8).

Input: parameters from last step θ (k-1) , φ φ φ (k-1) Output: updated parameters θ (k) , φ φ φ (k) 1. Generate samples {x 1,s } S s=1 via a discretized CTF: x0,s ∼ q φ φ φ (k-1) (x0), x1,s ∼ T1(x0,s); 2. Update the generator by minimizing ({x 0,s } S s=1 are generated with the updated parameter φ φ φ (k) ):

φ φ φ (k) = arg min φ φ φ D {x 1,s }, {x 0,s } .

3. Update the energy-based model θ k by maximum likelihood, with gradient as (9) except replacing

E x∼p θ (x) with E x∼q φ φ φ (x) ;

The gradient formula requires an integration over the model distribution p θ (x), which can be approximated by Monte Carlo integration with samples. The sampling problem has been well studied for some particular energy-based distributions, for example, via contrastive divergence in restricted Boltzmann machines (Hinton, 2002) . However, this does not fit into our setting directly. Here we adopt the idea of CTFs and propose to use a DNN guided by a CTF, which we call a generator, to generate approximate samples from the original model p θ (x). Specifically, we require that samples from the generator should well approximate the target p θ (x). This can be done by adopting the CTF idea above, i.e., distilling knowledge of a CTF (which approaches p θ (x)) to the generator. In testing, instead of generating samples from p θ (x) via MCMC (which is complicated and time consuming), we generate samples from the generator directly. Furthermore, when evaluating the likelihood for test data, the unknown constant Z(θ) of p θ (x) can also be approximated by Monte Carlo integration with samples drawn from the generator.

On the right side of ( 9), the first term is a model fit to observed data, and the (negative) second term is a model fit to synthetic data drawn from p θ(x) ; this is similar to the critic/discriminator in GANs (Arjovsky et al., 2017) , but derived directly from the MLE. More connections are discussed below. The goal is to match the samples x 0 from q φ φ φ to those after a CTF (x T ), or equivalently samples from p θ .

Our goal is to learn a generator whose generated samples match those from the original model p θ (x), by adopting the amortization idea with CTF in the inference section above. Similar to inference, the generator is learned implicitly. However, we also learn an explicit density model for the data by SGD, with samples from the implicit generator to estimate gradients in (9). Note that in this case, the CTF is performed directly on the data space, instead of on latentvariable space as in previous sections. Specifically, the sampling procedure from the generator plus a continuoustime-flow transformation are written as:

x 0 ∼ q φ φ φ (x 0 ), x T ∼ T (x 0 , T ) .

Here T (•, •) is the continuous-time flow; a sample x 0 from q φ φ φ (•) is implemented by a deep neural network (generator) G φ φ φ (ω) with input ω ∼ q 0 (ω), where q 0 is a simple distribution for a noise random variable, e.g., the standard isotropic normal distribution. The procedure is illustrated in Figure 3 . Note the CTF cannot be replaced by standard normalizing flow (Rezende & Mohamed, 2015) in this model, because there is no objective function to guide the update of parameters in normalizing flows, which is not necessary for CTFs.

Specifically, denote the parameters in the k-th step of our algorithm with subscript "(k)". For efficient sample generation, in the k-th step, we again adopt the amortization idea from Section 3.2 to update φ φ φ (k-1) of the generator network G φ φ φ (•), such that samples from the updated generator match those from the current generator followed by a one-step transformation T 1 (•). After that, θ is updated by drawing samples from q φ φ φ (•) to estimate the expectation in (9). The detailed algorithm is presented in Algorithm 1.

4.2. CONNECTIONS TO WASSERSTEIN GAN (WGAN) AND MLE:

There is an interesting relation between our model and the WGAN framework (Arjovsky et al., 2017) .

To see this, let p r be the data distribution. Substituting p θ (x) with q φ φ φ (x) for the expectation in the gradient formula (9) and integrating out θ, we have that our objective is

EQUATION

The objective is an instance of the general integral probability metrics (Arjovsky & Bottou, 2017) . When U is chosen to be 1-Lipschitz functions, it recovers WGAN. This connection motivates us to introduce weight clipping (Arjovsky et al., 2017) or alternative regularizers (Gulrajani et al., 2017) when updating θ for a better theoretical property. For this reason, we call our model Markov-chainbased GAN (MacGAN).

Furthermore, it can be shown by Jensen's inequality that the MLE is bounded by (detailed derivations are provided in Section C of the SM)

EQUATION

By inspecting ( 10) and ( 11), it is clear that: i) when learning the energy-based model parameters θ, the objective can be interpreted as maximizing an upper bound of the MLE shown in (11); ii) when optimizing the parameter φ φ φ of the inference network, we adopt the amortized learning procedure presented in Algorithm 1, whose objective is min φ φ φ KL (q φ φ φ p θ ), coinciding with the last two terms in (11). In other words, both θ and φ φ φ are optimized by maximizing the same upper bound of the MLE, guaranteeing convergence of the algorithm. Particularly, we can conclude that Proposition 4. The optimal solution of MacGAN is the maximum likelihood estimator.

Note another difference between MacGAN and standard GAN framework is the way of learning the generator q φ φ φ . We adopt the amortization idea, which directly guides q φ φ φ to approach p θ ; whereas in GAN, the generator is optimized via a min-max procedure to make it approach the empirical data distribution p r . By explicitly learning p θ , MacGAN is able to evaluate likelihood for test data (at least up to a constant).

5. RELATED WORK:

Our framework extends the idea of normalizing flows (Rezende & Mohamed, 2015) to continuoustime flows, by developing theoretical properties on the convergence behavior. Inference based on CTFs has been studied in Salimans et al. (2015) based on the auxiliary-variable technique. However, Salimans et al. (2015) directly uses discrete approximations for the flow, and the approximation accuracy is unclear. Moreover, the inference network requires simulating a long Markov chain for the auxiliary model, thus is less efficient than ours. Finally, the inference network is implemented as a parametric distribution (e.g., the Gaussian distribution), limiting the representation power, a common setting in existing auxiliary-variable based models (Tran et al., 2016) . The idea of amortization (Gershman & Goodman, 2014) has recently been explored in various research topics for Bayesian inference such as in variational inference (Kingma & Welling, 2014; Rezende et al., 2014) and Markov chain Monte Carlo (Wang & Liu, 2017; Li et al., 2017; Pu et al., 2017a) . Both Wang & Liu (2017) and Pu et al. (2017a) extend the idea of Stein variational gradient descent (Liu & Wang, 2016) with amortized inference for a GAN-based and a VAE-based model, respectively, which resemble our proposed MacVAE and MacGAN in concept. Li et al. (2017) applies amortization to distill knowledge from MCMC to learn a student network. The ideas in Li et al. (2017) are similar to ours, but the motivation and underlying theory are different from that developed here. The discretization stepsize h is robust as long as it is set in a reasonable range, e.g., we set it the same as the stepsize in SGD.

EQUATION

6.1. CTFS FOR INFERENCE:

Synthetic experiment We examine our amortized learning framework with a toy experiment. Following Rezende & Mohamed (2015) , we use MacVAE to approximate samples from a two dimensional distribution on z

= {z 1 , z 2 }: p(z) ∝ e -U (z) with U (z) 1 2 ( z -2 0.4 ) 2 -ln(e -1 2 [ z 1 -2 0.6 ] 2 + e -1 2 [ z 1 +2 0.6 ] 2

). The inference network q φ φ φ is defined to be a 2-layer MLP with isotropic normal random variables as input. Figure 4 (top) plots the densities estimated with the samples from transformations {T K=100 } (before optimizing φ φ φ), as well as with samples generated directly from q φ φ φ (after optimizing φ φ φ). It is clear that the amortized learning is able to distill knowledge from the CTF to the inference network. Rezende & Mohamed (2015) ; Tomczak & Welling (2016) , we define the inference network as a deep neural network with two fully connected layers of size 300 with softplus activation functions. We compare MacVAE with the standard VAE and the VAE with normalizing flow, where testing ELBOs are reported (Section D.1 of the SM describes how to calculate the ELBO). We do not compare with other state-of-the-art methods such as the inverse autoregressive flow (Kingma et al., 2016) , because they typically endowed more complicated inference networks (with more parameters), unfair for comparison. We use the same inference network architecture for all the models. Figure 4 (bottom) plots the testing ELBO versus training epochs. MacVAE outperforms VAE and normalizing flows with a better ELBO (around -85.62).

MacVAE on MNIST Following:



6.2. CTFS FOR DENSITY ESTIMATION:

We test MacGAN on three datasets: MNIST, CIFAR-10 and CelabA. Following GAN-related methods, the model is evaluated by observing its ability to draw samples from the learned data distribution. Inspiring by Wang & Liu (2017) , we define a parametric form of the energy-based model as p θ (x) ∝ exp{-x -DEC θ (ENC θ (x))

2 }, where ENC θ (•) and DEC θ (•) are encoder and decoder defined by using deep convolutional neural networks and deconvolutional neural networks, respectively, parameterized by θ. For simplicity, we adopt the popular DCGAN architecture (Radford et al., 2016) for the encoder and decoder. The generator G φ φ φ is defined as a 3-layer convolutional neural network with the ReLU activation function (except for the top layer which uses tanh as the activation function, see SM D for details). Following Wang & Liu (2017) , the stepsizes are set to (me-e)×lr me-50 , where e indexes the epoch, m e is the total number of epochs, l r = 1e-4 when updating θ, and l r = 1e-3 when updating φ φ φ. The stepsize in L 1 is set to 1e-3.

We compare MacGAN with DCGAN (Radford et al., 2016) , the improved WGAN (WGAN-I) (Gulrajani et al., 2017) and SteinGAN (Wang & Liu, 2017) . We plot images generated with MacGAN and its most related method SteinGAN in Figure 5 are provided in SM Section D. We observe that visually MacGAN is able to generate clear-looking images. Following Wang & Liu (2017) , we also plot the images generated by a random walk in the ω space in Figure 5 . Qualitatively evaluating a GAN-like model is challenging. We follow literature and use the inception score (Salimans et al., 2016) to measure the quantity of the generated images. Figure 6 We study the problem of applying CTFs for efficient inference and explicit density estimation in deep generative models, two important tasks in unsupervised machine learning. Compared to discrete-time normalized flows, CTFs are more general and flexible due to the fact that their stationary distributions can be controlled without extra flow parameters. We develop theory on the approximation accuracy when adopting a CTF to approximate a target distribution. We apply CTFs on two classes of deep generative models, a variational autoencoder for efficient inference, and a GAN-like density estimator for explicit density estimation and efficient data generation. Experiments show encouraging results of our framework in both models compared to existing techniques. One interesting direction of future work is to explore more efficient learning algorithms for the proposed CTF-based framework.

ψ(z)p θ (x, z)d z. When using a numerical integrator to solve (2) to get samples {z k } K k=1 , the sample average ψK 1 K K k=1 ψ(z k ) is used to approximate the posterior average. The accuracy is characterized by the mean square error (MSE) defined as: E ψKψ 2 . Lemma 6 derives the bound for the MSE. Lemma 6 (Vollmer et al. (2016) ). Under Assumption 1, and for a 1st-order numerical intergrator, the MSE is bounded, for a constant C independent of h and K, by

E ψK -ψ 2 ≤ C 1 hK + h 2 .

Furthermore, except for the 2nd-order Wasserstein distance defined in Lemma 1, we define the 1st-order Wasserstein distance between two probability measures µ 1 and µ 2 as W 1 (µ 1 , µ 2 ) inf p∈P(µ1,µ2)

xy 2 p(d x, d y) .

According to the Kantorovich-Rubinstein duality Arjovsky et al. (2017) , W 1 (µ 1 , µ 2 ) is equivalently represented as

EQUATION

where L 1 is the space of 1-Lipschitz functions f : R L → R.

We have the following relation between W 1 (µ 1 , µ 2 ) and W 2 (µ 1 , µ 2 ). Lemma 7 (Givens & Shortt (1984) ). We have for any two distributions µ 1 and µ 2 that W 1 (µ 1 , µ 2 ) ≤ W 2 (µ 1 , µ 2 ).

Now it is ready to prove Theorem 2.

Proof of Theorem 2. The idea is to simply decompose the MSE into two parts, with one part charactering the MSE of the numerical method, the other part charactering the MSE of ρ T and p θ (x, z), which consequentially can be bounded using Lemma 5 above. 

:

† We reuse the notation T as transformations from the discrete case above for simplicity, and use Z instead of z (reserved for the discrete-time setting) to denote the random variable in the continuous-time setting.‡ Note we define continuous-time flows in terms of latent variable Z in order to incorporate it into the setting of inference. However, the same description applies when we define the flow in data space, which is the setting of density estimation in Section 4.

§ Such structure can represent much more complex distributions than a parametric form, useful for following procedures. We argue an explicit distribution form is not as important in inference as that in density estimation.

¶ This is distinct from our density-estimation framework described in the next section, where an explicit form is assumed at the beginning for practical needs.

EXPERIMENTSWe conduct experiments to test our CTF-based framework for efficient inference and density estimation described above, and compared them with related methods. The implementation is based on the excellent code for SteinGANWang & Liu (2017), where we adopt their default parameter setting. https://github.com/DartML/SteinGAN

Figures and Tables:

Figure 1: Discretized approximation (right) of a continuous-time flow (left). Densities {ρ k } of {z k } evolve via transformations {T k }, with ρk → ρ hk when h → 0 for each k due to Lemma 1.

Figure3: Learning a generator with CTF. The goal is to match the samples x 0 from q φ φ φ to those after a CTF (x T ), or equivalently samples from p θ .

Figure 4: Knowledge distillation from the CTF (left) and ELBO versus epochs on MNIST (right). VAE with 80-layer NF is not included because it has much more parameters.

Figure 5: Generated images for CIFAR-10 (top) and CelebA (middle) datasets with MacGAN (left) and SteinGAN (right). The bottom are images generated by a random walk on the ω space for the generator of MacGAN, i.e., ω t = ω t-1 + 0.03 × rand([-1, 1]).

Figure 6: Inception score versus epochs for different models.

Figure 8: Generated images for CelebA datasets with MacGAN.

Figure 9: Generated images for CIFAR-10 datasets with MacGAN.

Figure 10: Generated images for CelebA datasets with SteinGAN.

Figure12: Generated images with a random walk on the ω space for CelebA datasets with MacGAN, ω t = ω t-1 + 0.02 × rand([-1, 1]).

Peer review (iclr2018):
 The authors try to use continuous time generalizations of normalizing flows for improving upon VAE-like models or for standard density estimation problems. Clarity: the text is mathematically very sloppy / hand-wavy. 1. I do not understand proposition (1). I do not think that the proof is correct (e.g. the generator L needs to be applied to a function -- the notation L(x) does not make too much sense): indeed, in the case when the volatility is zero (or very small), this proposition would imply that any vector field induces a volume preserving transformation, which is indeed false. 2. I do not really see how the sequence of minimization Eq(5) helps in practice. The Wasserstein term is difficult to hand. 3. in Equation (6), I do not really understand what is if is an empirical distribution. One really needs to be a probability density to make sense of that.