GO GRADIENT FOR EXPECTATION-BASED OBJECTIVES
Year: 2019

Abstract:
Within many machine learning algorithms, a fundamental problem concerns efficient calculation of an unbiased gradient wrt parameters γ for expectation-based objectives Eqγ(y)[f(y)]. Most existing methods either (i) suffer from high variance, seeking help from (often) complicated variance-reduction techniques; or (ii) they only apply to reparameterizable continuous random variables and employ a reparameterization trick. To address these limitations, we propose a General and One-sample (GO) gradient that (i) applies to many distributions associated with non-reparameterizable continuous or discrete random variables, and (ii) has the same low-variance as the reparameterization trick. We find that the GO gradient often works well in practice based on only one Monte Carlo sample (although one can of course use more samples if desired). Alongside the GO gradient, we develop a means of propagating the chain rule through distributions, yielding statistical back-propagation, coupling neural networks to common random variables.

heading: 1 INTRODUCTION
text: Neural networks, typically trained using back-propagation for parameter optimization, have recently demonstrated significant success across a wide range of applications. There has been interest in coupling neural networks with random variables, so as to embrace greater descriptive capacity. Recent examples of this include black-box variational inference (BBVI) (Kingma & Welling, 2014; Rezende et al., 2014; Ranganath et al., 2014; Hernández-Lobato et al., 2016; Ranganath et al., 2016b; Li & Turner, 2016; Ranganath et al., 2016a; Zhang et al., 2018) and generative adversarial networks (GANs) (Goodfellow et al., 2014; Radford et al., 2015; Zhao et al., 2016; Arjovsky et al., 2017; Li et al., 2017; Gan et al., 2017; Li et al., 2018). Unfortunately, efficiently backpropagating gradients through general distributions (random variables) remains a bottleneck. Most current methodology focuses on distributions with continuous random variables, for which the reparameterization trick may be readily applied (Kingma & Welling, 2014; Grathwohl et al., 2017).
As an example, the aforementioned bottleneck greatly constrains the applicability of BBVI, by limiting variational approximations to reparameterizable distributions. This limitation excludes discrete random variables and many types of continuous ones. From the perspective of GAN, the need to employ reparameterization has constrained most applications to continuous observations. There are many forms of data that are more-naturally discrete.
The fundamental problem associated with the aforementioned challenges is the need to efficiently calculate an unbiased low-variance gradient wrt parameters γ for an expectation objective of the form Eqγ(y)[f(y)]1. We are interested in general distributions qγ(y), for which the components of y may be either continuous or discrete. Typically the components of y have a hierarchical structure, and a subset of the components of y play a role in evaluating f(y).
Unfortunately, classical methods for estimating gradients of Eqγ(y)[f(y)] wrt γ have limitations. The REINFORCE gradient (Williams, 1992), although generally applicable (e.g., for continuous and discrete random variables), exhibits high variance with Monte Carlo (MC) estimation of the ∗Correspondence to: Yulai Cong <yulaicong@gmail.com>, Miaoyun Zhao <miaoyun9zhao@gmail.com>. 1In this paper, we consider expectation objectives meeting basic assumptions: (i) qγ(y) is differentiable wrt γ; (ii) f(y) is differentiable for continuous y; and (iii) f(y) <∞ for discrete y. For simplicity of the main paper, those assumptions are implicitly made, as well as fundamental rules like Leibniz’s rule.
expectation, forcing one to apply additional variance-reduction techniques. The reparameterization trick (Rep) (Salimans et al., 2013; Kingma & Welling, 2014; Rezende et al., 2014) works well, with as few as only one MC sample, but it is limited to continuous reparameterizable y. Many efforts have been devoted to improving these two formulations, as detailed in Section 6. However, none of these methods is characterized by generalization (applicable to general distributions) and efficiency (working well with as few as one MC sample).
The key contributions of this work are based on the recognition that REINFORCE and Rep are seeking to solve the same objective, but in practice Rep yields lower-variance estimations, albeit for a narrower class of distributions. Recent work (Ranganath et al., 2016b) has made a connection between REINFORCE and Rep, recognizing that the former estimates a term the latter evaluates analytically. The high variance by which REINFORCE approximates this term manifests high variance in the gradient estimation. Extending these ideas, we make the following main contributions. (i) We propose a new General and One-sample (GO) gradient in Section 3, that principally generalizes Rep to many non-reparameterizable distributions and justifies two recent methods (Figurnov et al., 2018; Jankowiak & Obermeyer, 2018); the “One sample” motivating the name GO is meant to highlight the low variance of the proposed method, although of course one may use more than one sample if desired. (ii) We find that the core of the GO gradient is something we term a variable-nabla, which can be interpreted as the gradient of a random variable wrt a parameter. (iii) Utilizing variablenablas to propagate the chain rule through distributions, we broaden the applicability of the GO gradient in Sections 4-5 and present statistical back-propagation, a statistical generalization of classic back-propagation (Rumelhart & Hinton, 1986). Through this generalization, we may couple neural networks to general random variables, and compute needed gradients with low variance.

heading: 2 BACKGROUND
text: To motivate this paper, we begin by briefly elucidating common machine learning problems for which there is a need to efficiently estimate gradients of γ for functions of the form Eqγ(y)[f(y)]. Assume access to data samples {xi}i=1,N , drawn i.i.d. from the true (and unknown) underlying distribution q(x). We seek to learn a model pθ(x) to approximate q(x). A classic approach to such learning is to maximize the expected log likelihood θ̂ = argmaxθ Eq(x)[log pθ(x)], perhaps with an added regularization term on θ. Expectation Eq(x)(·) is approximated via the available data samples, as θ̂ = argmaxθ 1 N ∑N i=1 log pθ(xi).
It is often convenient to employ a model with latent variables z, i.e., pθ(x) = ∫ pθ(x, z)dz =∫
pθ(x|z)p(z)dz, with prior p(z) on z. The integral wrt z is typically intractable, motivating introduction of the approximate posterior qφ(z|x), with parameters φ. The well-known evidence lower bound (ELBO) (Jordan et al., 1999; Bishop, 2006) is defined as
ELBO(θ,φ;x) = Eqφ(z|x)[log pθ(x, z)− log qφ(z|x)] (1) = log pθ(x)− KL[qφ(z|x)‖pθ(z|x)] ≤ log pθ(x) (2)
where pθ(z|x) is the true posterior, and KL(·‖·) represents the Kullback-Leibler divergence. Variational learning seeks (θ̂, φ̂) = argmaxθ,φ ∑N i=1 ELBO(θ,φ;xi).
While computation of the ELBO has been considered for many years, a problem introduced recently concerns adversarial learning of pθ(x), or, more precisely, learning a model that allows one to efficiently and accurately draw samples x ∼ pθ(x) that are similar to x ∼ q(x). With generative adversarial networks (GANs) (Goodfellow et al., 2014), one seeks to solve
min θ max β
{ Eq(x)[logDβ(x)] + Epθ(x)[log(1−Dβ(x))] } , (3)
where Dβ(x) is a discriminator with parameters β, quantifying the probability x was drawn from q(x), with 1−Dβ(x) representing the probability that it was drawn from pθ(x). There have been many recent extensions of GAN (Radford et al., 2015; Zhao et al., 2016; Arjovsky et al., 2017; Li et al., 2017; Gan et al., 2017; Li et al., 2018), but the basic setup in (3) holds for most.
To optimize (1) and (3), the most challenging gradients that must be computed are of the form ∇γEqγ(y)[f(y)]; for (1) y = z and γ = φ, while for (3) y = x and γ = θ. The need to evaluate expressions like∇γEqγ(y)[f(y)] arises in many other machine learning problems, and consequently it has generated much prior attention.
Evaluation of the gradient of the expectation is simplified if the gradient can be moved inside the expectation. REINFORCE (Williams, 1992) is based on the identity
∇γEqγ(y)[f(y)] = Eqγ(y) [ f(y)∇γ log qγ(y) ] . (4)
While simple in concept, this estimate is known to have high variance when the expectation Eqγ(y)(·) is approximated (as needed in practice) by a finite number of samples.
An approach (Salimans et al., 2013; Kingma & Welling, 2014; Rezende et al., 2014) that has attracted recent attention is termed the reparameterization trick, applicable when qγ(y) can be reparametrized as y = τγ( ), with ∼ q( ), where τγ( ) is a differentiable transformation and q( ) is a simple distribution that may be readily sampled. To keep consistency with the literature, we call a distribution reparameterizable if and only if those conditions are satisfied2. In this case we have
∇γEqγ(y)[f(y)] = Eq( ) [ [∇γτγ( )][∇yf(y)]|y=τγ( ) ] . (5)
This gradient, termed Rep, is typically characterized by relatively low variance, when approximating Eq( )(·) with a small number of samples ∼ q( ). This approach has been widely employed for computation of the ELBO and within GAN, but it limits one to models that satisfy the assumptions of Rep.

heading: 3 GO GRADIENT
text: The reparameterization trick (Rep) is limited to reparameterizable random variables y with continuous components. There are situations for which Rep is not readily applicable, e.g., where the components of y may be discrete or nonnegative Gamma distributed. We seek to gain insights from the relationship between REINFORCE and Rep, and generalize the types of random variables y for which the latter approach may be effected. We term our proposed approach a General and One-sample (GO) gradient. In practice, we find that this approach works well with as few as one sample for evaluating the expectation, and it is applicable to more general settings than Rep.
Recall that Rep was first applied within the context of variational learning (Kingma & Welling, 2014), as in (1). Specifically, it was assumed qγ(y) = ∏ v qγ(yv), omitting explicit dependence on data x, for notational convenience; yv is component v of y. In Kingma & Welling (2014) qγ(yv) corresponded to a Gaussian distribution qγ(yv) = N (yv;µv(γ), σ2v(γ)), with mean µv(γ) and variance σ2v(γ). In the following we generalize qγ(yv) such that it need not be Gaussian. Applying integration by parts (Ranganath et al., 2016b)
∇γEqγ(y)[f(y)] = ∑
v Eqγ(y−v)
[∫ f(y)∇γqγ(yv)dyv ] (6)
= ∑
v Eqγ(y−v)
[ [ f(y)∇γQγ(yv) ]∣∣∞ −∞︸ ︷︷ ︸
“0”
− ∫
[∇γQγ(yv)][∇yvf(y)]dyv︸ ︷︷ ︸ “Key”
] , (7)
where y−v denotes y with yv excluded, and Qγ(yv) is the cumulative distribution function (CDF) of qγ(yv). The “0” term is readily proven to be zero for any Qγ(yv), with the assumption that f(y) doesn’t tend to infinity faster than∇γQγ(yv) tending to zero when yv → ±∞. The “Key” term exactly recovers the one-dimensional Rep when reparameterization yv = τγ( v), v ∼ q( v) exists (Ranganath et al., 2016b). Further, applying ∇γqγ(yv) = qγ(yv)∇γ log qγ(yv) in (6) yields REINFORCE. Consequently, it appears that Rep yields low variance by analytically setting to zero the unnecessary but high-variance-injecting “0” term, while in contrast REINFORCE implicitly seeks to numerically implement both terms in (7).
We generalize qγ(y) for discrete yv, here assuming yv ∈ {0, 1, . . . ,∞}. It is shown in Appendix A.2 that this framework is also applicable to discrete yv with a finite alphabet. It may be shown (see Appendix A.2) that
∇γEqγ(y)[f(y)] = ∑
v Eqγ(y−v) [∑ yv f(y)∇γqγ(yv) ] = ∑
v Eqγ(y−v) [ [f(y)∇γQγ(yv)]|yv=∞︸ ︷︷ ︸
“0”
− ∑
yv [∇γQγ(yv)][f(y−v, yv + 1)− f(y)]︸ ︷︷ ︸
“Key”
] (8)
2A Bernoulli random variable y ∼ Bernoulli(P ) is identical to y = 1 <P with ∼ U(0, 1). But y is called non-reparameterizable because the transformation y = 1 <P is not differentiable.
where Qγ(yv) = ∑yv n=0 qγ(n), and Qγ(∞) = 1 for all γ. Theorem 1 (GO Gradient). For expectation objectives Eqγ(y)[f(y)], where qγ(y) satisfies (i) qγ(y) = ∏ v qγ(yv); (ii) the corresponding CDF Qγ(yv) is differentiable wrt parameters γ; and (iii) one can calculate∇γQγ(yv), the General and One-sample (GO) gradient is defined as
∇γEqγ(y)[f(y)] = Eqγ(y) [ Gqγ(y)γ Dy[f(y)] ] , (9)
where Gqγ(y)γ specifies Gq(y)κ , [ · · · , gq(yv)κ , · · · ] with variable-nabla gq(yv)κ , −1q(yv)∇κQ(yv),
Dy[f(y)] = [ · · · ,Dyv [f(y)], · · · ]T , and
Dyv [f(y)] , { ∇yvf(y), Continous yv f(y−v, yv + 1)− f(y), Discrete yv
All proofs are provided in Appendix A, where we also list gqγ(yv)γ for a wide selection of possible qγ(y), for both continuous and discrete y. Note for the special case with continuous y, GO reduces to Implicit Rep gradients (Figurnov et al., 2018) and pathwise derivatives (Jankowiak & Obermeyer, 2018); in other words, GO provides a principled explanation for their low variance, namely their foundation (implicit differentiation) originates from integration by parts. For high-dimensional discrete y, calculating Dy[f(y)] is computationally expensive. Fortunately, for f(y) often used in practice special properties hold that can be exploited for efficient parallel computing. Also for discrete yv with finite support, it is possible that one could analytically evaluate a part of expectations in (9) for lower variance, mimicking the local idea in Titsias & Lázaro-Gredilla (2015); Titsias (2015). Appendix I shows an example illustrating how to handle these two issues in practice.

heading: 4 DEEP GO GRADIENT
text: The GO gradient in Theorem 1 can only handle single-layer mean-field qγ(y), characterized by an independence assumption on the components of y. One may enlarge the descriptive capability of qγ(y) by modeling it as a marginal distribution of a deep model (Ranganath et al., 2016b; Bishop, 2006). Hereafter, we focus on this situation, and begin with a 2-layer model for simple demonstration. Specifically, consider
qγ(y) = ∫ qγ(y,λ)dλ = ∫ qγy (y|λ)qγλ(λ)dλ = ∫ ∏ v qγy (yv|λ) · ∏ k qγλ(λk)dλ,
where γ = {γy,γλ}, y is the leaf variable, and the internal variable λ is assumed to be continuous. Components of y are assumed to be conditionally independent given λ, but upon marginalizing out λ this independence is removed.
The objective becomes Eqγ(y)[f(y)] = Eqγy (y|λ)qγλ (λ)[f(y)], and via Theorem 1 ∇γyEqγ(y)[f(y)] = Eqγ(y,λ) [ G qγy (y|λ) γy Dy[f(y)] ] . (10)
Lemma 1. Equation (10) exactly recovers the Rep gradient in (5), if γ = γy and qγ(y) has reparameterization y = τγ(λ), λ ∼ q(λ) for differentiable τγ(λ) and easily sampled q(λ).
Lemma 1 shows that Rep is a special case of our deep GO gradient in the following Theorem 2. Note neither Implicit Rep gradients nor pathwise derivatives can recover Rep in general, because a neural-network-parameterized y = τγ(λ) may lead to non-trivial CDF Qγ(y).
For the gradient wrt γλ, we first apply Theorem 1, yielding ∇γλEqγ(y)[f(y)] = Eqγλ (λ) [ Gqγλ (λ)γλ Dλ [ Eqγy (y|λ)[f(y)] ]] .
For continuous internal variable λ one can apply Theorem 1 again, from which ∇γλEqγ(y)[f(y)] = Eqγ(y,λ) [ Gqγλ (λ)γλ G qγy (y|λ) λ Dy[f(y)] ] . (11)
Now extending the same procedure to deeper models with L layers, we generalize the GO gradient in Theorem 2. Random variable y(L) is assumed to be the leaf variable of interest, and may be continuous or discrete; latent/internal random variables {y(1), . . . ,y(L−1)} are assumed continuous (these generalize λ from above).
Theorem 2 (Deep GO Gradient). For expectation objectives Eqγ(y(L))[f(y (L))] with qγ(y(L)) being the marginal distribution of
qγ ( y(1), · · · ,y(L) ) = qγ(1) ( y(1) )[∏L l=2 qγ(l) ( y(l)|y(l−1) )] ,
where γ = {γ(1), · · · ,γ(L)}, all internal variables y(1), · · · ,y(L−1) are continuous, the leaf variable y(L) is either continuous or discrete, qγ(l)(y(l)|y(l−1)) = ∏ v qγ(l)(y (l) v |y(l−1)), and one has access to variable-nablas g q γ(l) (y(l)v |y (l−1))
γ(l) and g
q γ(l) (y(l)v |y (l−1)) y(l−1) , as defined in Theorem 1, the
General and One-sample (GO) gradient is defined as
∇γ(l)Eqγ(y(L))[f(y (L))] = Eqγ(y(1),··· ,y(L))
[ G q γ(l)
(y(l)|y(l−1)) γ(l)
BP [ y(l) ]] , (12)
where BP[y(L)] = Dy(L) [f(y(L))] and BP[y(l)] = G q γ(l+1) (y(l+1)|y(l)) y(l)
BP[y(l+1)] for l < L. Corollary 1. The deep GO gradient in Theorem 2 exactly recovers back-propagation (Rumelhart & Hinton, 1986) when each element distribution qγ(l)(y (l) v |y(l−1)) is specified as the Dirac delta function located at the activated value after activation function.
Figure 1 is presented for better understanding. With variable-nablas, one can readily verify that the deep GO gradient in Theorem 2 in expectation obeys the chain rule.

heading: 5 STATISTICAL BACK-PROPAGATION AND HIERARCHICAL VARIATIONAL INFERENCE
text: Recall the motivating discussion in Section 2, in which we considered generative model pθ(x, z) and inference model qφ(z|x), the former used to model synthesis of the observed datax and the latter used for inference of z given observed x. In recent deep architectures, a hierarchical representation for cumulative latent variables z = (z(1), . . . ,z(L)) has been considered (Rezende et al., 2014; Ranganath et al., 2015; Zhou et al., 2015; 2016; Ranganath et al., 2016b; Cong et al., 2017; Zhang et al., 2018). As an example, there are models with pθ(x, z) = pθ(x|z(1)) [∏L−1 l=1 pθ(z (l)|z(l+1)) ] pθ(z
(L)). When performing inference for such models, it is intuitive to consider first-order Markov chain structure for qφ(z|x) = qφ(z(1)|x) ∏L l=2 qφ(z
(l)|z(l−1)). The discussion in this section is most relevant for variational inference, for computation of ∇φEqφ(z(1),...,z(L)|x)[f(z
(1), . . . ,z(L))], and consequently we specialize to that notation in the subsequent discussion (we consider representations in terms of z, rather than the more general y notation employed in Section 4).
Before proceeding, we seek to make clear the distinction between this section and Section 4. In the latter, only the leaf variable z(L) appears in∇γEqγ(z(L))[f(z (L))]; see (12), with y(L) → z(L). That
is because in Section 4 the underlying model is a marginal distribution of z(L), i.e., qγ(z(L)), which is relevant to the generators of GANs; see (3), with x→ z(L) and pθ(x)→ qγ(z(L)). Random variables z(1), . . . ,z(L−1) were marginalized out of qγ(z(1), . . . ,z(L−1), z(L)) to represent qγ(z(L)). As discussed in Section 4, z(1), . . . ,z(L−1) were added there to enhance the modeling flexibility of qγ(z(L)). In this section, the deep set of random variables z = (z(1), . . . ,z(L)) are inherent components of the underlying generative model for x, i.e., pθ(x, z) = pθ(x, z(1), . . . ,z(L)). Hence, all components of z manifested via inference model qφ(z|x) = qφ(z(1), . . . ,z(L)|x) play a role in f(z). Besides, no specific structure is imposed on pθ(x, z) and qφ(z|x) in this section, moving beyond the aforementioned first-order Markov structure. For a practical application, one may employ domain knowledge to design suitable graphical models for pθ(x, z) and qφ(z|x), and then use the following Theorem 3 for training. Theorem 3 (Statistical Back-Propagation). For expectation objectives
Eqφ({z(i)}Li=1) [ f({z(i)}Li=1) ] ,
where {z(i)}Ii=1 denotes I continuous internal variables with at least one child variable, {z(j)}Lj=I+1 represents L − I continuous or discrete leaf variables with no children except f(·), and qφ(·) is constructed as a hierarchical probabilistic graphical model
qφ({z(i)}Li=1) = qφ({z(i)}Ii=1) ∏L
j=I+1 qφ(z
(j)|{z(i)}Ii=1)
with each element distribution qφ(zv|pa(zv)) having accessible variable-nablas as defined in Theorem 1, pa(zv) denotes the parent variables of zv, the General and One-sample (GO) gradient for φk ∈ φ is defined as
∇φkEqφ({z(i)}Li=1) [ f({z(i)}Li=1) ] = Eqφ({z(i)}Li=1) [ Gqφ[ch(φk)]φk BP[ch(φk)] ] , (13)
where ch(φk) denotes the children variables of φk, and with zv ∈ ch(φk),
Gqφ[ch(φk)]φk = [· · · , g qφ(zv|pa(zv)) φk , · · · ], BP[ch(φk)] = [· · · ,BP[zv], · · · ]T ,
and BP[zv] is iteratively calculated as BP[zv] = G qφ[ch(zv)] zv BP[ch(zv)], until leaf variables where BP[zv] = Dzv [f({z(i)}Li=1)].
Statistical back-propagation in Theorem 3 is relevant to hierarchical variational inference (HVI) (Ranganath et al., 2016b; Hoffman & Blei, 2015; Mnih & Gregor, 2014) (see Appendix G), greatly generalizing GO gradients to the inference of directed acyclic probabilistic graphical models. In HVI variational distributions are specified as hierarchical graphical models constructed by neural networks. Using statistical back-propagation, one may rely on GO gradients to perform HVI with low variance, while greatly broadening modeling flexibility.

heading: 6 RELATED WORK
text: There are many methods directed toward low-variance gradients for expectation-based objectives. Attracted by the generalization of REINFORCE, many works try to improve its performance via efficient variance-reduction techniques, like control variants (Mnih & Gregor, 2014; Titsias & LázaroGredilla, 2015; Gu et al., 2015; Mnih & Rezende, 2016; Tucker et al., 2017; Grathwohl et al., 2017) or via data augmentation and permutation techniques (Yin & Zhou, 2018). Most of this research focuses on discrete random variables, likely because Rep (if it exists) works well for continuous random variables but it may not exist for discrete random variables. Other efforts are devoted to continuously relaxing discrete variables, to combine both REINFORCE and Rep for variance reduction (Jang et al., 2016; Maddison et al., 2016; Tucker et al., 2017; Grathwohl et al., 2017).
Inspired by the low variance of Rep, there are methods that try to generalize its scope. The Generalized Rep (GRep) gradient (Ruiz et al., 2016) employs an approximate reparameterization whose transformed distribution weakly depends on the parameters of interest. Rejection sampling variational inference (RSVI) (Naesseth et al., 2016) exploits highly-tuned transformations in mature rejection sampling simulation to better approximate Rep for non-reparameterizable distributions. Compared
to the aforementioned methods, the proposed GO gradient, containing Rep as a special case for continuous random variables, applies to both continuous and discrete random variables with the same low-variance as the Rep gradient. Implicit Rep gradients (Figurnov et al., 2018) and pathwise derivatives (Jankowiak & Obermeyer, 2018) are recent low-variance methods that exploit the gradient of the expected function; they are special cases of GO in the single-layer continuous settings.
The idea of gradient backpropagation through random variables has been exploited before. RELAX (Grathwohl et al., 2017), employing neural-network-parametrized control variants to assist REINFORCE for that goal, has a variance potentially as low as the Rep gradient. SCG (Schulman et al., 2015) utilizes the generalizability of REINFORCE to construct widely-applicable stochastic computation graphs. However, REINFORCE is known to have high variance, especially for highdimensional problems, where the proposed methods are preferable when applicable (Schulman et al., 2015). Stochastic back-propagation (Rezende et al., 2014; Fan et al., 2015), focusing mainly on reparameterizable Gaussian random variables and deep latent Gaussian models, exploits the product rule for an integral to derive gradient backpropagation through several continuous random variables. By comparison, the proposed statistical back-propagation based on the GO gradient is applicable to most distributions for continuous random variables. Further, it also flexibly generalizes to hierarchical probabilistic graphical models with continuous internal variables and continuous/discrete leaf ones.

heading: 7 EXPERIMENTS
text: We examine the proposed GO gradients and statistical back-propagation with four experiments: (i) simple one-dimensional (gamma and negative binomial) examples are presented to verify the GO gradient in Theorem 1, corresponding to nonnegative and discrete random variables; (ii) the discrete variational autoencoder experiment from Tucker et al. (2017) and Grathwohl et al. (2017) is reproduced to compare GO with the state-of-the-art variance-reduction methods; (iii) a multinomial GAN, generating discrete observations, is constructed to demonstrate the deep GO gradient in Theorem 2; (iv) hierarchical variational inference (HVI) for two deep non-conjugate Bayesian models is developed to verify statistical back-propagation in Theorem 3. Note the experiments of Figurnov et al. (2018) and Jankowiak & Obermeyer (2018) additionally support our GO in the single-layer continuous settings.
Many mature machine learning frameworks, like TensorFlow (Abadi et al.) and PyTorch (Paszke et al., 2017), are optimized for implementation of methods like back-propagation. Fortunately, all gradient calculations in the proposed theorems obey the chain rule in expectation, enabling convenient incorporation of the proposed approaches into existing frameworks. Experiments presented below were implemented in TensorFlow or PyTorch with a Titan Xp GPU. Code for all experiments can be found at github.com/YulaiCong/GOgradient.
Notation Gam(α, β) denotes the gamma distribution with shape α and rate β, NB(r, P ) the negative binomial distribution with number of failures r and success probability P , Bern(P ) the Bernoulli distribution with probability P , Mult(n,P ) the multinomial distribution with number of trials n and event probabilities P , Pois(λ) the Poisson distribution with rate λ, and Dir(α) the Dirichlet distribution with concentration parameters α.

heading: 7.1 GAMMA AND NB ONE-DIMENSIONAL SIMPLE EXAMPLES
text: We first consider illustrative one-dimensional “toy” problems, to examine the GO gradient for both continuous and discrete random variables. The optimization objective is expressed as
max φ ELBO(φ) = Eqφ(z)[log p(z|x)− log qφ(z)] + log p(x),
where for continuous z we assume p(z|x) = Gam(z;α0, β0) for given set (α0, β0), with qφ(z) = Gam(z;α, β) and φ = {α, β}; for discrete z we assume p(z|x) = NB(z; r0, p0) for given set (r0, p0), with qφ(z) = NB(z; r, p) and φ = {r, p}. Stochastic gradient ascent with onesample-estimated gradients is used to optimize the objective, which is equivalent to minimizing KL(qφ(z)‖p(z|x)). Figure 2 shows the results (see Appendix H for additional details). For the nonnegative continuous z associated with the gamma distribution, we compare our GO gradient with GRep (Ruiz et al., 2016),
RSVI (Naesseth et al., 2016), and their modified version using the “sticking” idea (Roeder et al., 2017), denoted as GRep-Stick and RSVI-Stick, respectively. For RSVI and RSVI-Stick, the shape augmentation parameter is set as 5 by default. The only difference between GRep and GRep-Stick (also RSVI and RSVI-Stick) is the latter does not analytically express the entropy Eqφ(z)[− log qφ(z)]. Figure 2(a) clearly shows the utility of employing sticking to reduce variance; without it, GRep and RSVI exhibit high variance, that destabilizes the optimization for small gamma shape parameters, as shown in Figures 2(b) and 2(c). We adopt the sticking approach hereafter for all the compared methods. Among methods with sticking, GO exhibits the lowest variance in general, as shown in Figures 2(a) and 2(b). GO empirically provides more stable learning curves, as shown in Figure 2(c). For the discrete case corresponding to the NB distribution, GO is compared to REINFORCE (Williams, 1992). To address the concern about comparison with the same number of evaluations of the expected function3, another curve of REINFORCE using 2 samples is also added, termed REINFORCE2. It is apparent from Figure 2(d) that, thanks to analytically removing the “0” terms in (8), the GO gradient has much lower variance, even in this simple one-dimensional case.

heading: 7.2 DISCRETE VARIATIONAL AUTOENCODER
text: To demonstrate the low variance of the proposed GO gradient, we consider the discrete variational autoencoder (VAE) experiment from REBAR (Tucker et al., 2017) and RELAX (Grathwohl et al., 2017), to make a direct comparison with state-of-the-art variance-reduction methods. Since the statistical back-propagation in Theorem 3 cannot handle discrete internal variables, we focus on the single-latent-layer settings (1 layer of 200 Bernoulli random variables), i.e.,
pθ(x, z) : x ∼ Bern ( NNPx|z (z) ) , z ∼ Bern ( P z )
qφ(z|x) : z ∼ Bern ( NNP z|x(x) ) where P z is the parameters of the prior pθ(z), NNPx|z (z) means using a neural network to project the latent binary code z to the parametersP x|z of the likelihood pθ(x|z), and NNP z|x(x) is similarly defined for qφ(z|x). The objective is given in (1). See Appendix I for more details.
3In the NB experiments, REINFORCE uses 1 sample and 1 evaluation of the expected function; REINFORCE2 uses 2 sample and 2 evaluations; and GO uses 1 sample and 2 evaluations.
Figure 3 (also Figure 9 of Appendix I) shows the training curves versus iteration and running time for the compared methods. Even without any variance-reduction techniques, GO provides better performance, faster convergence rate, and better running efficiency (about ten times faster in achieving the best training ELBO of RERAR/RELAX in this experiment). We believe GO’s better performance originates from: (i) its inherent low-variance nature; (ii) GO has less parameters compared to REBAR and RELAX (no control variant is adopted for GO); (iii) efficient batch processing methods (see Appendix I) are adopted to benefit from parallel computing. Table 1 presents the best training/validation ELBOs under various experimental settings for the compared methods. GO provides the best performance in all situations. Additional experimental results are given in Appendix I.
Many variance-reduction techniques can be used to further reduce the variance of GO, especially when complicated models are of interest. Compared to RELAX, GO cannot be directly applied when f(y) is not computable or where the interested model has discrete internal variables (like multilayer Sigmoid belief networks (Neal, 1992)). For the latter issue, we present in Appendix B.4 a procedure to assist GO (or statistical back-propagation in Theorem 3) in handling discrete internal variables.

heading: 7.3 MULTINOMIAL GAN
text: To demonstrate the deep GO gradient in Theorem 2, we adopt multinomial leaf variables x and construct a new multinomial GAN (denoted as MNGAN-GO) for generating discrete observations with a finite alphabet. The corresponding generator pθ(x) is expressed as
∼ N (0, I),x ∼ Mult(1,NNP( )). For brevity, we integrate the generator’s parameters θ into the NN notation, and do not explicitly express them. Details for this example are provided in Appendix J.
We compare MNGAN-GO with the recently proposed boundary-seeking GAN (BGAN) (Hjelm et al., 2018) on 1-bit (1-state, Bernoulli leaf variables x), 1-bit (2-state), 2-bit (4-state), 3-bit (8-state) and
4github.com/duvenaud/relax
4-bit (16-state) discrete image generation tasks, using quantized MNIST datasets (LeCun et al., 1998). Table 2 presents inception scores (Salimans et al., 2016) of both methods. MNGAN-GO performs better in general. Further, with GO’s assistance, MNGAN-GO shows more potential to benefit from richer information coming from more quantized states. For demonstration, Figure 4 shows the generated samples from the 4-bit experiment, where better image quality and higher diversity are observed for the samples from MNGAN-GO.

heading: 7.4 HVI FOR DEEP EXPONENTIAL FAMILIES AND DEEP LATENT DIRICHLET ALLOCATION
text: To demonstrate statistical back-propagation in Theorem 3, we design variational inference nets for two nonconjugate hierarchical Bayesian models, i.e., deep exponential families (DEF) (Ranganath et al., 2015) and deep latent Dirichlet allocation (DLDA) (Zhou et al., 2015; 2016; Cong et al., 2017).
DEF : x ∼ Pois(W(1)z(1)), z(l) ∼ Gam ( αz, αz/W(l+1)z(l+1) ) ,W(l) ∼ Gam(α0, β0)
DLDA : x ∼ Pois(Φ(1)z(1)), z(l) ∼ Gam ( Φ(l+1)z(l+1), c(l+1) ) ,Φ(l) ∼ Dir(η0).
For demonstration, we design the inference nets qφ(z|x) following the first-order Markov chain construction in Section 5, namely
qφ(z|x) : z(1) ∼ Gam ( NN(1)α (x),NN (1) β (x) ) , z(l) ∼ Gam ( NN(l)α (z (l−1)),NN(l)β (z (l−1)) ) .
Further details are provided in Appendix K. One might also wish to design inference nets that have structure beyond the above first-order Markov chain construction, as in Zhang et al. (2018); we do not consider that here, but Theorem 3 is applicable to that case.
HVI for a 2-layer DEF is first performed, with the ELBO curves shown in Figure 5. GO enables faster and more stable convergence. Figure 6 presents the HVI results for a 3-layer DLDA, for which stable ELBOs are again observed. More importantly, with the GO gradient, one can utilize pure gradient-based methods to efficiently train such complicated nonconjugate models for meaningful dictionaries (see Appendix K for more implementary details).

heading: 8 CONCLUSIONS
text: For expectation-based objectives, we propose a General and One-sample (GO) gradient that applies to continuous and discrete random variables. We further generalize the GO gradient to cases for which the underlying model is deep and has a marginal distribution corresponding to the latent variables of interest, and to cases for which the latent variables are hierarchical. The GO-gradient setup is demonstrated to yield the same low-variance estimation as the reparameterization trick, which is only applicable to reparameterizable continuous random variables. Alongside the GO gradient, we constitute a means of propagating the chain rule through distributions. Accordingly, we present statistical back-propagation, to flexibly integrate deep neural networks with general classes of random variables.

heading: ACKNOWLEDGMENTS
text: We thank the anonymous reviewers for their useful comments. The research was supported by part by DARPA, DOE, NIH, NSF and ONR. The Titan Xp GPU used was donated by the NVIDIA Corporation. We also wish to thank Chenyang Tao, Liqun Chen, and Chunyuan Li for helpful discussions.

heading: A PROOF OF THEOREM 1
text: We first prove (7) in the main manuscript, followed by its discrete counterpart, i.e., (8) in the main manuscript. Then, it is easy to verify Theorem 1.
A.1 PROOF OF EQUATION (7) IN THE MAIN MANUSCRIPT
Similar proof in one-dimension is also given in the supplemental materials of Ranganath et al. (2016b).
We want to calculate ∇γEqγ(y)[f(y)] = ∇γE∏v qγ(yv)[f(y)] = ∑ v Eqγ(y−v) [ ∫ f(y)∇γqγ(yv)dyv ] ,
where y−v denotes y with yv excluded. Without loss of generality, we assume yv ∈ (−∞,∞). Let v′(yv) = ∇γqγ(yv), and we have
v(yv) = ∫ yv −∞ ∇γqγ(t)dt = ∇γ ∫ yv −∞ qγ(t)dt = ∇γQγ(yv),
where Qγ(yv) is the cumulative distribution function (CDF) of qγ(yv). Further define u(yv) = f(yv,y−v), we then apply integration by parts (or partial integration) to get
∇γEqγ(y)[f(y)] = ∑
v Eqγ(y−v)
[ ∫ u(yv)v ′(yv)dyv ]
= ∑
v Eqγ(y−v)
[ u(yv)v(yv)|∞−∞ − ∫ u′(yv)v(yv)dyv ] = ∑
v Eqγ(y−v) [ f(y)∇γQγ(yv)|∞−∞︸ ︷︷ ︸
“0”
− ∫
[∇γQγ(yv)][∇yvf(y)]dyv︸ ︷︷ ︸ “Key”
] . (14)
With Qγ(∞) = 1 and Qγ(−∞) = 0, it’s straightforward to verify that the first term is always zero for any Qγ(yv), thus named the “0” term.
A.2 PROOF OF EQUATION (8) IN THE MAIN MANUSCRIPT
For discrete variables y, we have ∇γEqγ(y)[f(y)] = ∑
v Eqγ(y−v) [∑N yv=0 f(y)∇γqγ(yv) ] ,
where yv ∈ {0, 1, · · · , N} and N is the size of the alphabet. To handle the summation of products of two sequences and develop discrete counterpart of (7), we first introduce Abel transformation. Abel transformation. Given two sequences {an} and {bn}, with n ∈ {0, · · · , N}, we define B0 = b0 and Bn = ∑n k=0 bn for n ≥ 1. Accordingly, we have
SN = ∑N
n=0 anbn = a0b0 + ∑N n=1 an(Bn −Bn−1)
= a0B0 + ∑N
n=1 anBn − ∑N−1 n=0 an+1Bn
= aNBN + ∑N−1
n=0 anBn − ∑N−1 n=0 an+1Bn
= aNBN − ∑N−1
n=0 (an+1 − an)Bn.
Substituting n = yv, an = f(y), bn = ∇γqγ(yv), and Bn = ∇γQγ(yv) into the above equation, we have ∇γEqγ(y)[f(y)] =∑
v Eqγ(y−v) [ f(y−v, yv = N)∇γQγ(yv = N)︸ ︷︷ ︸
“0”
− ∑N−1
yv=0 [f(y−v, yv + 1)− f(y)]∇γQγ(yv)︸ ︷︷ ︸
“Key”
] .
Note the first term equals zero for both finite alphabet, i.e., N < ∞, and infinite alphabet, i.e., N =∞. When N =∞, we get (8) in the main manuscript. With the above proofs for Eqs. (7) and (8), one could straightforwardly verify Theorem 1.
ψ(x) is the digamma function. Γ(x, y) is the upper incomplete gamma function. B(x;α, β) is the incomplete beta function. pFq(a1, · · · , ap; b1, · · · , bp;x) is the generalized hypergeometric function. T (m, s, x) is a special case of Meijer G-function (Geddes et al., 1990).
B WHY DISCRETE Internal VARIABLES ARE CHALLENGING?
For simpler demonstration, we first use a 2-layer model to show why discrete internal variables are challenging. Then, we present an importance-sampling proposal that might be useful under specific situations. Finally, we present a strategy to learn discrete internal variables with the statistical back-propagation in Theorem 3 of the main manuscript.
Assume qγ(y) being the marginal distribution of the following 2-layer model
qγ(y) = Eqγλ (λ)[qγy (y|λ)] where γ = {γy,γλ}, qγ(y,λ) = qγy (y|λ)qγλ(λ) = ∏ v qγy (yv|λ) · ∏ k qγλ(λk), and both the leaf variable y and the internal variable λ could be either continuous or discrete.
Accordingly, the objective becomes
Eqγ(y)[f(y)] = Eqγ(y,λ)[f(y)] = Eqγy (y|λ)qγλ (λ)[f(y)].
For gradient wrt γy , using Theorem 1, it is straight to show ∇γyEqγ(y,λ)[f(y)] = Eqγλ (λ) [ ∇γyEqγy (y|λ)[f(y)] ] = Eqγ(y,λ) [ G qγy (y|λ) γy Dy[f(y)] ] . (15)
For gradient wrt γλ, we first have ∇γλEqγ(y,λ)[f(y)] = ∇γλEqγλ (λ) [ Eqγy (y|λ)[f(y)] ] .
With f̂(λ) = Eqγy (y|λ)[f(y)], we then apply Theorem 1 and get ∇γλEqγ(y,λ)[f(y)] = Eqγλ (λ) [ Gqγλ (λ)γλ Dλ[f̂(λ)] ] , (16)
where Dλ[f̂(λ)] = [· · · ,Dλk [f̂(λ)], · · · ]T , and
Dλk [f̂(λ)] , { ∇λk f̂(λ), Continous λk f̂(λ−k, λk + 1)− f̂(λ), Discrete λk
Next, we separately discuss the situations where λk is continuous or discrete.
B.1 FOR CONTINUOUS λk
One can directly apply Theorem 1 again, namely Dλk [f̂(λ)] = ∇λkEqγy (y|λ)[f(y)] = Eqγy (y|λ) [ G qγy (y|λ) λk Dy[f(y)] ] . (17)
Substituting (17) into (16), we have ∇γλEqγ(y,λ)[f(y)] = Eqγ(y,λ) [ Gqγλ (λ)γλ G qγy (y|λ) λ Dy[f(y)] ] . (18)
B.2 FOR DISCRETE λk
In this case, we need to calculate Dλk [f̂(λ)] = f̂(λ−k, λk + 1)− f̂(λ). The keys are again partial integration and Abel transformation. For simplicity, we first assume one-dimensional y, and separately discuss y being continuous and discrete.
For continuous y, we apply partial integration to f̂(λ) and get f̂(λ) = Eqγy (y|λ)[f(y)] = ∫ qγy (y|λ)f(y)dy
= [ f(y)Qγy (y|λ) ]∣∣∞ −∞ − ∫ Qγy (y|λ)∇yf(y)dy.
Accordingly, we have
Dλk [f̂(λ)] = f̂(λ−k, λk + 1)− f̂(λ)
= ∫ [ Qγy (y|λ)−Qγy (y|λ−k, λk + 1) ] ∇yf(y)dy
+ [ f(y)Qγy (y|λ−k, λk + 1) ]∣∣∞ −∞ − [ f(y)Qγy (y|λ) ]∣∣∞ −∞︸ ︷︷ ︸
“0”
.
Removing the “0” term, we have Dλk [f̂(λ)] = ∫ [ Qγy (y|λ)−Qγy (y|λ−k, λk + 1) ] ∇yf(y)dy. (19)
For discrete y, by similarly exploiting Abel transformation, we have f̂(λ) = Eqγy (y|λ)[f(y)] = ∑ y qγy (y|λ)f(y)
= f(∞)Qγy (∞|λ)− ∑
y Qγy (y|λ)
[ f(y + 1)− f(y) ] .
Accordingly, we get Dλk [f̂(λ)] = ∑
y
[ Qγy (y|λ)−Qγy (y|λ−k, λk + 1) ][ f(y + 1)− f(y) ] . (20)
Unifying (19) for continuous y and (20) for discrete y, we have
Dλk [f̂(λ)] = f̂(λ−k, λk + 1)− f̂(λ) = Eqγy (y|λ−k,λk+1)[f(y)]− Eqγy (y|λ)[f(y)]
= Eqγy (y|λ) [ Dy[f(y)] · ḡ qγy (y|λ) λk ] (21) where we define
ḡ qγy (y|λ) λk
, Qγy (y|λ)−Qγy (y|λ−k, λk + 1)
qγy (y|λ) .
Multi-dimensional y. Based on the above one-dimensional foundation, we next move on to multidimensional situations. With definitions y:i , {y1, · · · , yi} and yi: , {yi, · · · , yV }, where V is the dimensionality of y, we have
Dλk [f̂(λ)] = f̂(λ−k, λk + 1)− f̂(λ) = Eqγy (y|λ−k,λk+1)[f(y)]− Eqγy (y|λ)[f(y)]
= Eqγy (y2:|λ−k,λk+1) [ Eqγy (y1|λ−k,λk+1)[f(y)]− Eqγy (y1|λ)[f(y)]
+ Eqγy (y1|λ)[f(y)] ] − Eqγy (y|λ)[f(y)]
(22)
Apply (21) and we have Dλk [f̂(λ)] = Eqγy (y2:|λ−k,λk+1) [ Eqγy (y1|λ) [ Dy1 [f(y)] · ḡ qγy (y1|λ) λk ]] + Eqγy (y2:|λ−k,λk+1) [ Eqγy (y1|λ)[f(y)] ] − Eqγy (y|λ)[f(y)]
= Eqγy (y2:|λ−k,λk+1)qγy (y1|λ) [ Dy1 [f(y)] · ḡ qγy (y1|λ) λk + f(y) ] − Eqγy (y|λ)[f(y)]
Similarly, we add extra terms to the above equation to enable applying (21) again as Dλk [f̂(λ)] = Eqγy (y2:|λ−k,λk+1)qγy (y1|λ) [ Dy1 [f(y)] · ḡ qγy (y1|λ) λk + f(y) ]
− Eqγy (y3:|λ−k,λk+1)qγy (y:2|λ) [ Dy1 [f(y)] · ḡ qγy (y1|λ) λk + f(y) ]
+ Eqγy (y3:|λ−k,λk+1)qγy (y:2|λ) [ Dy1 [f(y)] · ḡ qγy (y1|λ) λk + f(y) ]
− Eqγy (y|λ)[f(y)].
Accordingly, we apply (21) to the first two terms and have Dλk [f̂(λ)] = Eqγy (y3:|λ−k,λk+1)qγy (y:2|λ) [ Dy2 [ Dy1 [f(y)]ḡ qγy (y1|λ) λk + f(y) ] ḡ qγy (y2|λ) λk ] + Eqγy (y3:|λ−k,λk+1)qγy (y:2|λ) [ Dy1 [f(y)]ḡ qγy (y1|λ) λk + f(y) ] − Eqγy (y|λ)[f(y)]
= Eqγy (y3:|λ−k,λk+1)qγy (y:2|λ)
Dy2 [ Dy1 [f(y)]ḡ qγy (y1|λ) λk + f(y) ] ḡ qγy (y2|λ) λk
+ Dy1 [f(y)]ḡ qγy (y1|λ) λk + f(y)  − Eqγy (y|λ)[f(y)]
So forth, we summarize the pattern into the following equation as
Dλk [f̂(λ)] = Eqγy (y|λ) [Aλk(y, V )− f(y)] , (23)
where Aλk(y, V ) is iteratively calculated as Aλk(y, 0) = f(y)
Aλk(y, v) = Dyv [ Aλk(y, v − 1) ] ḡ qγy (yv|λ) λk + Aλk(y, v − 1)
Aλk(y, V ) = DyV [ Aλk(y, V − 1) ] ḡ qγy (yV |λ) λk + Aλk(y, V − 1).
Despite elegant structures within (23), to calculate it, one must iterate over all dimensions of y, which is computational expensive in practice. More importantly, it is straightforward to show that deeper models will have similar but much more complicated expressions.
B.3 AN IMPORTANCE-SAMPLING PROPOSAL TO HANDLE DISCRETE Internal VARIABLES
Next, we present an intuitive proposal that might be useful under specific situations.
The key idea is to use different extra items to enable “easy-to-use” expression for Dλk [f̂(λ)], namely
Dλk [f̂(λ)] = f̂(λ−k, λk + 1)− f̂(λ) = Eqγy (y|λ−k,λk+1)[f(y)]− Eqγy (y|λ)[f(y)] = Eqγy (y|λ−k,λk+1)[f(y)]
− Eqγy (y:V−1|λ−k,λk+1)qγy (yV |λ)[f(y)] + Eqγy (y:V−1|λ−k,λk+1)qγy (yV |λ)[f(y)]
· · · − Eqγy (y:i−1|λ−k,λk+1)qγy (yi:|λ)[f(y)] + Eqγy (y:i−1|λ−k,λk+1)qγy (yi:|λ)[f(y)]
· · · − Eqγy (y1|λ−k,λk+1)qγy (y2:|λ)[f(y)] + Eqγy (y1|λ−k,λk+1)qγy (y2:|λ)[f(y)]
− Eqγy (y|λ)[f(y)].
Apply (21) to the adjacent two terms for V times, we have Dλk [f̂(λ)] = Eqγy (y:V−1|λ−k,λk+1)qγy (yV |λ) [ DyV [f(y)]ḡ qγy (yV |λ) λk ] · · ·
+ Eqγy (y:i−1|λ−k,λk+1)qγy (yi:|λ) [ Dyi [f(y)]ḡ qγy (yi|λ) λk ] · · ·
+ Eqγy (yV |λ) [ Dy1 [f(y)]ḡ qγy (y1|λ) λk ] ,
where we can apply the idea of importance sampling and modify the above equation to Dλk [f̂(λ)] = Eqγy (y|λ) [ DyV [f(y)]ḡ qγy (yV |λ) λk
qγy (y:V−1|λ−k, λk + 1) qγy (y:V−1|λ) ] · · ·
+ Eqγy (y|λ) [ Dyi [f(y)]ḡ qγy (yi|λ) λk
qγy (y:i−1|λ−k, λk + 1) qγy (y:i−1|λ) ] · · ·
+ Eqγy (yV |λ) [ Dy1 [f(y)]ḡ qγy (y1|λ) λk ] = Eqγy (y|λ) [ V∑ v=1 Dyv [ f(y) ] ḡ qγy (yv|λ) λk qγy (y:v−1|λ−k, λk + 1) qγy (y:v−1|λ) ] .
(24)
Note that importance sampling may not always work well in practice (Bishop, 2006).
We further define the generalized variable-nabla as
gg qγy (yv|λ) λk ,  −1 qγy (yv|λ) ∇λkQγy (yv|λ), Continuous λk
Qγy (yv|λ)−Qγy (yv|λ−k, λk + 1) qγy (yv|λ) qγy (y:v−1|λ−k, λk + 1) qγy (y:v−1|λ) , Discrete λk
(25)
With the generalized variable-nabla, we unify (24) for discrete λk and (17) for continuous λk and get Dλk [f̂(λ)] = Eqγy (y|λ) [∑
v
Dyv [f(y)] · gg qγ(yv|λ) λk
] ,
which apparently obeys the chain rule. Accordingly, we have the gradient for γλ in (16) as ∇γλEqγ(y,λ)[f(y)] = Eqγ(y,λ) [∑
k [∑ v Dyv [f(y)] · gg qγ(yv|λ) λk ] · ggqγλ (λk)γλ ] .
One can straightforwardly verify that, with the generalized variable-nabla defined in (25), the chain rule applies to∇γEqγ(y(L))[f(y
(L))], where one can freely specify both leaf and internal variables to be either continuous or discrete. The only problem is that, for discrete internal variables, the importance sampling trick used in (24) may not always work as expected.
B.4 STRATEGY TO LEARN DISCRETE INTERNAL VARIABLES WITH STATISTICAL BACK-PROPAGATION
Practically, if one has to deal with a qγ(y(1), · · · ,y(L)) with discrete internal variables y(l), l < L, we suggest the strategy in Figure 7, with which one should expect a close performance but enjoy much easier implementation with statistical back-propagation in Theorem 3 of the main manuscript. In fact, one can always add additional continuous internal variables to the graphical models to remedy the performance loss or even boost the performance.

heading: C PROOF OF LEMMA 1
text: First, a marginal distribution qγ(y) with reparameterization y = τγ( ), ∼ q( ) can be expressed as a joint distribution, namely
qγ(y) = qγ(y, ) = qγ(y| )q( ),
where qγ(y| ) = δ(y−τγ( )), δ(·) is the Dirac delta function, and τγ( ) could be flexibly specified as a injective, surjective, or bijective function.
Next, we align notations and rewrite (10) as ∇γEqγ(y)[f(y)] = Eqγ(y, ) [ Gqγ(y| )γ Dy[f(y)] ] = Eq( ) [ Eqγ(y| ) [ Gqγ(y| )γ Dy[f(y)] ]] ,
(26)
where Gqγ(y| )γ = [ · · · , gqγ(yv| )γ , · · · ] and gqγ(yv| )γ , −1qγ(yv| )∇γQγ(yv| ).
With qγ(yv| ) = δ(yv − [τγ( )]v), we have Qγ(yv| ) = {
1 [τγ( )]v ≤ yv 0 [τγ( )]v > yv
Accordingly, we have
∇γQγ(yv| ) = ∇[τγ( )]vQγ(yv| ) · ∇γ [τγ( )]v = −δ([τγ( )]v − yv) · ∇γ [τγ( )]v
and g qγ(yv| ) γ =
−1 qγ(yv| ) ∇γQγ(yv| ) = ∇γ [τγ( )]v.
Substituting the above equations into (26), we get ∇γEqγ(y)[f(y)] = Eq( ) [ [∇γτγ( )][∇yf(y)]|y=τγ( ) ] , (27)
which is the multi-dimensional Rep gradient in (5) of the main manuscript.

heading: D PROOF OF THEOREM 2
text: Firstly, with the internal variable λ being continuous, (10) and (11) in the main manuscript are proved by (15) and (18) in Section B, respectively. Then, by iteratively generalizing the similar derivations to deep models and utilizing the fact that the GO gradients with variable-nablas in expectation obey the chain rule for models with continuous internal variables, Theorem 2 could be readily verified.

heading: E PROOFS FOR COROLLARY 1
text: When all qγ(i) ( y(i)|y(i−1) ) s are specified as Dirac delta functions, namely
qγ(i) ( y(i)|y(i−1) ) = δ(y(i) − σ(γ(i),y(i−1))),
where σ(γ(i),y(i−1)) denotes the activated values after activation functions, the objective becomes
Eqγ(y(L))[f(y (L))] = f(y(L)) = f(σ(γ(L),y(L−1)))
= f(σ(γ(L),σ(γ(L−1),y(L−1))))
= f(σ(γ(L),σ(γ(L−1), · · · ,σ(γ(1)))) = f(γ),
(28)
where γ = {γ(1), · · · ,γ(N)}. Back-Propagation. For the objective in (28), the Back-Propagation is expressed as
∇γ(i)f(γ) = [∇γ(i)y(i)][∇y(i)f(·)], (29) where
∇y(i)f(·) = [∇y(i)y(i+1)][∇y(i+1)f(·)].
Deep GO Gradient. We consider the continuous special case, where Dy(L) [ f(y(L)) ] = ∇y(L)f(y(L)).
With qγ(i+1) ( y(i+1)|y(i) ) s being Dirac delta functions, namely,
qγ(i+1) ( y (i+1) k |y (i) ) = { ∞, [σ(γ(i+1),y(i))]k = y(i+1)k 0, [σ(γ(i+1),y(i))]k 6= y(i+1)k
we have
Qγ(i+1) ( y (i+1) k |y (i) ) = { 1, [σ(γ(i+1),y(i))]k ≤ y(i+1)k 0, [σ(γ(i+1),y(i))]k > y (i+1) k
Taking derivative wrt y(i)v , we got
∇ y (i) v Qγ(i+1)
( y
(i+1) k |y
(i) )
= ∇[σ(γ(i+1),y(i))]kQγ(i+1) ( y (i+1) k |y (i) ) · ∇
y (i) v
[σ(γ(i+1),y(i))]k = −δ ( [σ(γ(i+1),y(i))]k − y(i+1)k ) · ∇
y (i) v
[σ(γ(i+1),y(i))]k
Accordingly, we have
g q γ(i+1)
(y (i+1) k |y (i))
y (i) v
= −1
qγ(i+1)(y (i+1) k |y(i))
∇ y (i) v Qγ(i+1)(y (i+1) k |y (i))
= ∇ y (i) v [σ(γ(i+1),y(i))]k = ∇y(i)v y (i+1) k
By substituting the above equation into (12) in Theorem 2, and then comparing it with(29), one can easily verify Corollary 1.

heading: F PROOF FOR THEOREM 3
text: Based on the proofs for Theorem 1 and Theorem 2, it is clear that, if one constrains all internal variables to be continuous, the GO gradients in expectation obey the chain rule. Therefore, one can straightforwardly utilizing the chain rule to verify Theorem 3. Actually, Theorem 3 may be seen as the chain rule generalized with random variables, among which the internal ones are only allowed to be continuous.

heading: G DERIVATIONS FOR HIERARCHICAL VARIATIONAL INFERENCE
text: In Hierarchical Variational Inference, the objective is to maximize the evidence lower Bound (ELBO)
ELBO(θ,φ;x) = Eqφ(z|x)[log pθ(x, z)− log qφ(z|x)]. (30) For the common case with z = {z(1), · · · , z(L)}, it is obvious that Theorem 3 of the main manuscript can be applied when optimizing φ.
Practically, there are situations where one might further put a latent variable λ in reference qφ(z|x), namely qφ(z|x) = ∫ qφz (z|λ)qφλ(λ)dλ with φ = {φz,φλ}. Following Ranganath et al. (2016b), we briefly discuss this situation here.
We first show that there is another unnecessary variance-injecting “0” term. ∇φELBO(θ,φ;x) = ∫ [∇φqφ(z|x)][log pθ(x, z)− log qφ(z|x)]dz
− ∫ qφ(z|x)∇φ log qφ(z|x)dz︸ ︷︷ ︸
“0”
, (31)
where the second “0” term is straightly verified as∫ qφ(z|x)∇φ log qφ(z|x)dz = ∫ ∇φqφ(z|x)dz = ∇φ ∫ qφ(z|x)dz = ∇φ1 = 0.
Eliminating the “0” term from (31), one still has another problem, that is, log qφ(z|x) is usually non-trivial when qφ(z|x) is marginal. For this problem, we follow Ranganath et al. (2016b) to use another lower bound ELBO2 of the ELBO in (30).
− log qφ(z|x) = ∫ qφ(λ|z,x)[− log qφ(z|x)]dλ = ∫ qφ(λ|z,x) [ − log qφ(z,λ|x)
qφ(λ|z,x)
] dλ
= Eqφ(λ|z,x) [ − log qφ(z,λ|x)
rω(λ|z,x) + log qφ(λ|z,x) rω(λ|z,x) ] ≥ Eqφ(λ|z,x) [ − log qφ(z,λ|x)
rω(λ|z,x)
]
where rω(λ|z,x), evaluable, is an additional variational distribution to approximate the variational posterior qφ(λ|z,x). Accordingly, we get the ELBO2 for Hierarchical Variational Inference as
ELBO2(θ,φ;x) = Eqφ(z,λ|x) [ log pθ(x, z)− log qφ(z,λ|x) + log rω(λ|z,x) ] .
Note similar to (31), the unnecessary “0” term related to log qφ(z,λ|x) should also be removed. Accordingly, we have
∇φELBO2(θ,φ;x) = ∫ [ ∇φqφ(z,λ|x) ][ log pθ(x, z)−log qφ(z,λ|x)+log rω(λ|z,x) ] dλdz.
Obviously, Theorem 3 is readily applicable to provide GO gradients.

heading: H DETAILS OF GAMMA AND NB ONE-DIMENSIONAL SIMPLE EXAMPLES
text: We first consider illustrative one-dimensional “toy” problems, to examine the GO gradient in Theorem 1 for both continuous and discrete random variables.
The optimization objective is expressed as max φ ELBO(φ) = Eqφ(z)[log p(z|x)− log qφ(z)] + log p(x),
where for continuous z we assume p(z|x) = Gam(z;α0, β0) for set (α0, β0), with qφ(z) = Gam(z;α, β) and φ = {α, β}; for discrete z we assume p(z|x) = NB(z; r0, p0) for set (r0, p0), with qφ(z) = NB(z; r, p) and φ = {r, p}. Stochastic gradient ascent with one-sample-estimated gradients is used to optimize the objective, which is equivalent to minimizing KL(qφ(z)‖p(z|x)). Figure 8 shows the experimental results. For the nonnegative continuous z associated with the gamma distribution, we compare our GO gradient with GRep (Ruiz et al., 2016), RSVI (Naesseth et al., 2016), and their modified version using the “sticking” idea (Roeder et al., 2017), denoted as GRep-Stick and RSVI-Stick respectively. For RSVI and RSVI-Stick, the shape augmentation parameter is set as 5 by default. The only difference between GRep and GRep-Stick (also RSVI and RSVI-Stick) is the latter does NOT analytically express the entropy Eqφ(z)[− log qφ(z)]. One should apply sticking because (i) Figures 8(a)-8(c) clearly show its utility in reducing variance; and (ii) without it, GRep and RSVI exhibit high variance that unstabilizes the optimization for small gamma shape parameters, as shown in Figures 8(d)-8(f). We adopt the sticking approach hereafter for all the compared methods. Since the gamma rate parameter β is reparameterizable, its gradient calculation is the same for all sticking methods, including GO, GRep-Stick, and RSVI-Stick. Therefore, similar variances are observed in Figures 8(b) and 8(e). Among methods with sticking, GO exhibits the lowest variance in general, as shown in Figures 8(a) and 8(d). Note it is high variance that causes optimization issues. As a result, GO empirically provides more stable learning curves, as shown in Figures 8(c) and 8(f). For the discrete case corresponding to the NB distribution, GO is compared to REINFORCE (Williams, 1992). To estimate gradient, REINFORCE uses 1 sample of z and 1 evaluation of the expected function; whereas GO uses 1 sample and 2 evaluations. To address the concern about comparison with the same number of evaluations of the expected function, another curve of REINFORCE using 2 samples (thus 2 evaluations of the expected function) is also added, termed REINFORCE2. It is apparent from Figures 8(g)-8(l) that, thanks to analytically removing the “0” terms, the GO gradient has much lower variance and thus faster convergence, even in this simple one-dimensional case.

heading: I DETAILS OF THE DISCRETE VAE EXPERIMENT
text: Complementing the discrete VAE experiment of the main manuscript, we present below its experimental settings, implementary details, and additional results.
Since the presented statistical back-propagation in Theorem 3 of the main manuscript cannot handle discrete internal variables, we focus on the single-latent-layer settings (1 layer of 200 Bernoulli random variables) for fairness, i.e.,
pθ(x, z) : x ∼ Bern ( NNPx|z (z) ) , z ∼ Bern ( P z )
qφ(z|x) : z ∼ Bern ( NNP z|x(x) ) .
(32)
Referring to the experimental settings in Grathwohl et al. (2017), we consider
• 1-layer linear model: NNPx|z (z) = σ(W T p z + bp)
NNP z|x(x) = σ(W T q x+ bq)
where σ(·) is the sigmoid function. • Nonlinear model:
NNPx|z (z) = σ(W T p2h (2) p +bp2),h (2) p = tanh(W T p1h (1) p +bp1),h (1) p = tanh(W T p z+bp)
NNP z|x(x) = σ(W T q2h (2) q +bq2),h (2) q = tanh(W T q1h (1) q +bq1),h (1) q = tanh(W T q x+bq) where tanh(·) is the hyperbolic-tangent function.
The used datasets and other experimental settings, including the hyperparameter search strategy, are the same as those in Grathwohl et al. (2017).
For such single-latent-layer settings, it is obvious that Theorem 3 (also Theorem 1) can be straightforwardly applied. However, since Bernoulli distribution has finite support, as mentioned in the main manuscript, we should analytically express some expectations for lower variance, as detailed below. Notations of (8) and (9) of the main manuscript are used for clarity and also for generalization.
In fact, we should take a step back and start from (8) of the main manuscript, which is equivalent to analytically express an expectation in (9), namely
∇γEqγ(y)[f(y)] = ∑
v Eqγ(y−v)
[ − ∑
yv [∇γQγ(yv)][f(y−v, yv + 1)− f(y)]
] , (33)
where Qγ(yv) = {
1− Pv(γ) yv = 0 1 yv = 1 with Pv(γ) being the Bernoulli probability of Bernoulli
random variable yv . Accordingly, we have ∇γEqγ(y)[f(y)] = − ∑
v Eqγ(y−v)
[ [∇γQγ(yv = 0)][f(y−v, yv = 1)− f(y−v, yv = 0)] ] = ∑
v Eqγ(y−v)
[ [∇γPv(γ)][f(y−v, yv = 1)− f(y−v, yv = 0)] ] = Eqγ(y) [∑ v [∇γPv(γ)][f(y−v, yv = 1)− f(y−v, yv = 0)] ] (34)
For better understanding only, with abused notations ∇γP = [· · · ,∇γPv(γ), · · · ]T , ∇Py = I, and ∇yf(y) = [· · · , {f(y−v, yv = 1)− f(y−v, yv = 0)}, · · · ]T , one should observe a chain rule within the above equation.
To assist better understanding of how to practically cooperate the presented GO gradients with deep learning frameworks like TensorFlow or PyTorch, we take (34) as an example, and present for it the following simple algorithm.
Algorithm 1 An algorithm for (34) as an example to demonstrate how to practically cooperate GO gradients with deep learning frameworks like TensorFlow or PyTorch. One sample is assumed for clarity. Practically, an easy-to-use trick for changing gradients of any function h(x) is to define ĥ(x) = xTStopGradient[g] + StopGradient[h(x)− xTg] with g the desired gradients.
# Forward-Propagation 1. γ → P (γ): Calculate Bernoulli probabilities P (γ ) 2. P (γ)→ y: Sample y ∼ Bern(P (γ)) . Change gradient: ∇P (γ)y = I 3. y → f(y): Calculate the loss f(y) . Change gradient: [∇yf(y)]v = f(y−v, yv = 1)− f(y−v, yv = 0) # Back-Propagation 1. Rely on the mature auto-differential software for back-propagating gradients
For efficient implementation of Dyf(y), one should exploit the prior knowledge of function f(y). For example, f(y)s are often neural-network-parameterized. Under that settings, one should be able to exploit tensor operation to design efficient implementation of Dyf(y). Again we take (34) as an example, and assume f(y) has the special structure
f(y) = r(ΘTh+ c),h = σ(WTy + b) (35) where σ(·) is an element-wise nonlinear activation function, and r(·) is a function that takes in a vector and outputs a scalar. One can easily modify the above f(y) for the considered discrete VAE experiment.
Since yvs are now Bernoulli random variables with support {0, 1}, we have that[ Dyf(y) ] v = f(y−v, yv = 1)− f(y−v, yv = 0)
= { f(y−v, yv + 1)− f(y) yv = 0 f(y)− f(y−v, yv − 1) yv = 1
= av[f(y−v, yv + av)− f(y)],
(36)
where av = { 1 yv = 0
− 1 yv = 1 is the v-th element of vector a.
Then to efficiently calculate the f(y−v, yv + av)s, we use the following batch processing procedure to benefit from parallel computing.
• Step 1: Define Ξyh as the matrix whose element [Ξyh]vj represents the “new” h∗j when input {y−v, yv + av} in (35). Then, we have
[Ξyh]vj = σ(y TW:j + bj + avWvj)
where W:j is the j-th column of the matrix W. Note the vth row of Ξyh, i.e., [Ξyh]v:, happens to be the “new” h∗ when input {y−v, yv + av}. • Step 2: Similarly, we define Ξyf as the vector whose element [Ξyf ]v = f(y−v, yv + av).
Utilizing Ξyh obtained in Step 1, we have
Ξyf = r([Ξyh]ϑ+ c T ),
where r(·) is applied to each row of the matrix ([Ξyh]ϑ+ cT ).
Note the above batch processing procedure can be easily extended to deeper neural networks. Accordingly, we have Dyf(y) = a [Ξyf − f(y)], where represents the matrix element-wise product. Now we can rely on Algorithm 1 to solve the problem whose objective has its gradient expressed as (34), for example the inference of the single-latent-layer discrete VAE in (32).
All training curves versus iteration/running-time are given in Figure 9, where it is apparent that GO provides better performance, a faster convergence rate, and a better running efficiency in all situations. The average running time per 100 iterations for the compared methods are given in Table 4, where GO is 2−4 times faster in finishing the same number of training iterations. We also quantify the running efficiency of GO by considering its running time to achieve the best training ELBO (within 1, 000, 000 training iterations) of RERAR/RELAX, referring to the black lines shown in the second-column subfigures of Figure 9. It is clear that GO is approximately 5− 10 times more efficient than REBAR/RELAX in the considered experiments.
As shown in the second and fourth rows of Figures 9, for the experiments with nonlinear models all methods suffer from over-fitting, which originates from the redundant complexity of the adopted neural networks and appeals for model regularizations. We detailedly clarify these experimental results as follows.
• All the compared methods are given the same and only objective, namely to maximize the training ELBO on the same training dataset with the same model; GO clearly shows its power in achieving a better objective.
• The “level” of over-fitting is ultimately determined by the used dataset, model, and objective; it is independent of the adopted optimization method. Different optimization methods just reveal different optimizing trajectories, which show different sequences of training objectives and over-fitting levels (validation objectives).
5github.com/duvenaud/relax
• Since all methods are given the same dataset, model, and objective, they have the same over-fitting level. Because GO has a lower variance, and thus more powerful optimization capacity, it gets to the similar situations much faster than REBAR/RELAX. Note this does not mean GO suffers more from over-fitting. In fact, GO provides better validation ELBOs in all situations, as shown in Figure 9 and also Table 1 of the main manuscript. In practice, GO can benefit from the early-stopping trick to get a better generalization ability.

heading: J DETAILS OF THE MULTINOMIAL GAN
text: Complementing the multinomial GAN experiment in the main manuscript, we present more details as follows. For a quantitative assessment of the computational complexity, our PyTorch code takes about 30 minutes to get the most challenging 4-bit task in Figs. 4 and 11, with a Titan Xp GPU.
Firstly, recall that the generator pθ(x) of the developed multinomial GAN (denoted as MNGAN-GO) is expressed as ∼ N (0, I),x ∼ Mult(1,NNP( )), where NNP( ) denotes use of a neural network to project to distribution parameters P. For brevity, we integration the generator’s parameters θ into the NN notation and do not explicitly express them. Multinomial leaf variables x is used to describe discrete observations with a finite alphabet. To train MNGAN-GO, the vanilla GAN loss (Goodfellow et al., 2014) is used. A deconvolutional neural network as in Radford et al. (2015) is used to map to P in the generator. The discriminator is constructed as a multilayer perceptron. Detailed model architectures are given in Table 5. Figure 10 illustrates the pipeline of MNGAN-GO. Note MNGAN-GO has a smaller number of parameters, compared to BGAN (Hjelm et al., 2018).
For clarity, we briefly discuss the employed data preprocessing. Taking MNIST for an example, the original data are 8-bit grayscale images, with pixel intensities ranging from 0 to 255. For the n-bit experiment, we obtain the real data, such as the 2-bit one in Figure 10, by rescaling and quantizing the pixel intensities to the range [0, 2n − 1], having 2n different states (values). For the 1-bit special case, the multinomial distribution reduces to the Bernoulli distribution. Of course, one could intuitively employ the redundant multinomial distribution, which is denoted as 1-bit (2-state) in Table 2. An alternative and popular approach is to adopt the Bernoulli distribution to remove the redundancy by only modeling its probability parameters; we denote this case as 1-bit (1-state, Bernoulli) in Table 2.
Figure 11 shows the generated samples from the compared models on different quantized MNIST. It is obvious that MNGAN-GO provides images with better quality and wider diversity in general.

heading: K DETAILS OF HVI FOR DEF AND DLDA
text: Complementing the HVI experiments in the main manuscript, we present more details as follows.
For a quantitative assessment of the computational complexity, the TensorFlow code used takes about 0.08 seconds per iteration (including > 40, 000 Meijer-G function calculations, with an approximate algorithm coded also with TensorFlow).
Deep exponential families (DEF) (Ranganath et al., 2015) is expressed as x ∼ Pois(W(1)z(1)), z(l) ∼ Gam ( αz, αz/W(l+1)z(l+1) ) ,W(l) ∼ Gam(α0, β0),
where αz = 0.1, α0 = 0.3, and β0 = 0.1 following Ruiz et al. (2016); Naesseth et al. (2016). Since the variables of interest, W(l) and z(l), are gamma-distributed, we design the variational approximations as
qφz (z|x) : z (1) ∼ Gam ( NN(1)α (x),NN (1) β (x) ) , z(l) ∼ Gam ( NN(l)α (z (l−1)),NN(l)β (z (l−1)) ) ,
qφW(W) : W (l) ∼ Gam
( α
(l) W,β (l) W
) ,
where NN(l)(·)s are set to the same shapes as the corresponding z(l), α(l)W and β (l) W also have the shape of W(l). We employ a simple two-layer DEF for demonstration, with z(1) and z(2) having 128 and 64 components, respectively. The mini-batch size is set to 200. One-sample gradient estimates are used to train the model for the compared methods. For RSVI (Naesseth et al., 2016), the shape augmentation parameter B is set to 5. All experimental settings, except for different ways to calculate gradients, are the same for the compared methods.
Deep latent Dirichlet allocation (DLDA) (Zhou et al., 2015; 2016; Cong et al., 2017) is expressed as x ∼Pois(Φ(1)z(1)), z(l) ∼ Gam ( Φ(l+1)z(l+1), c(l+1) ) , z(L) ∼ Gam ( r, c(L+1) ) ,
Φ(l) ∼ Dir(η0), c(l) ∼ Gam(e0, f0), r ∼ Gam(γ0/K, c0), (37)
where hyperparameters are chosen following Cong et al. (2017). Compared to DEF, DLDA is more complicated: 1) model is constructed via the highly nonlinear Gamma shape parameters; 2) dictionaries are described by more challenging Dirichlet distributions; 3) more interested random variables.
The variational approximations for DLDA are designed as qφ(z, c|x) :z(1) ∼ Gam ( NN(1)αz (x),NN (1) βz (x) ) , c(2) ∼ Gam ( NN(2)αc (z (1)),NN(2)βc (z (1)) ) ,
z(l) ∼ Gam ( NN(l)αz (z (l−1)),NN(l)βz (z (l−1)) ) , c(l+1) ∼ Gam ( NN(l+1)αc (z (l)),NN(l+1)βc (z (l)) ) ,
qφ(Φ) :Φ (l) ∼ Dir(η(l)),
qφ(r) :r ∼ Gam(αr,βr),
where motivated by the original upward-downward Gibbs sampler developed in Zhou et al. (2015), we specify NN(l)βz (·) as a scaler to mimic the Gibbs conditional posteriors. The other NN(·)s and also η(l),αr,βr have the same shapes of the corresponding random variables. A three-layer DLDA, having 128, 64, 32 components for latent z(1), z(2), z(3) respectively, is trained on MNIST with mini-batches of size 200.
With the learned variational inference nets, one could efficiently project the observed x to its latent variables z, c during testing. For applications requiring realtime processing, this is a clear advantage. For demonstration, Figure 12 shows test data samples x and their reconstruction
x̂ = Φ(1)ẑ(1), ẑ(1) ∼ Gam ( NN(1)αz (x),NN (1) βz (x) ) ,
where one Monte Carlo sample is used to calculate ẑ(1).
Note for the challenging DLDA task in (37), we find it tricky to naively apply pure-gradient-based learning methods. The main reason is: the latent code z(l)s and their gamma shape parameters Φ(l+1)z(l+1)s are usually extremely sparse, meaning most elements are almost zero; a gamma distribution z ∼ Gam(α, β) with almost-zero α has an increasingly steep slope when z approaches zero, namely the gradient wrt z shall have an enormous magnitude that unstablize the learning procedure. Even though it might not be sufficient to just use the first-order gradient information, empirically the following tricks help us get the presented reasonable results.
• Let z(l) ≥ Tz , where Tz = 1e−5 is used in the experiments; • Let c(l) ≥ Tc, where Tc = 1e−5; • Let Φ(l+1)z(l+1) ≥ Tα with Tα = 0.2; • Use a factor to compromise the likelihood and prior for each z(l).
For more details, please refer to our released code. We are working on exploiting higher-order information (such as Hessian) to help remedy this issue.

Review summaries:
This paper presents a gradient estimator for expectation-based objectives, which is called Go-gradient. This estimator is unbiased, has low variance and, in contrast to other previous approaches, applies to either continuous and discrete random variables. They also extend this estimator to problems where the gradient should be "backpropagated" through a nested combination of random variables and a (non-linear) functions. Authors present an extensive experimental evaluation of the estimator on different challenging machine learning problems.