Md. Asif Uddin
    I.13.X02

    One reparameterised gradient

    gradient▲△△

    Use the model of I.13.B01: w=3 u1\vec w=\sqrt3\,\vec u_1, σ2=1\sigma^2=1, x=(1,2)\vec x=(1,2), so wTx=23\vec w^{\mathsf T}\vec x=2\sqrt3 and ∥w∥2=3\|\vec w\|^2=3. The encoder returns m=0.5m=0.5 and s=0.5s=0.5, and the draw is ε=0.6\varepsilon=0.6. Compute the one-draw gradient of the ELBO with respect to mm and ss, then the exact gradient with respect to mm.

    Hint

    The reconstruction term is −∥x−wz∥2/2-\|\vec x-\vec wz\|^2/2 plus a constant, with z=m+sεz=m+s\varepsilon. The KL term is 12(m2+s2−1−log⁡s2)\tfrac12(m^2+s^2-1-\log s^2).

    Solution

    The code is z=0.5+0.5⋅0.6=0.8z=0.5+0.5\cdot0.6=0.8. The derivative of the reconstruction term with respect to zz is

    wT(x−wz)=23−3⋅0.8=1.064102.\begin{aligned} \vec w^{\mathsf T}(\vec x-\vec wz) &=2\sqrt3-3\cdot0.8\\ &=1.064102. \end{aligned}

    Since ∂z/∂m=1\partial z/\partial m=1 and ∂z/∂s=ε\partial z/\partial s=\varepsilon, and the KL has derivatives mm and s−1/ss-1/s,

    ∂∂m=1.064102−0.5=0.564102,∂∂s=1.064102⋅0.6−(0.5−2)=2.138461.\begin{aligned} \frac{\partial}{\partial m}&=1.064102-0.5=0.564102,\\ \frac{\partial}{\partial s}&=1.064102\cdot0.6-(0.5-2)\\ &=2.138461. \end{aligned}

    The exact gradient with respect to mm averages over ε\varepsilon. The reconstruction derivative is linear in zz, so its average is its value at z=mz=m: 23−1.5=1.9641022\sqrt3-1.5=1.964102. Subtracting the KL’s 0.50.5 gives 1.4641021.464102. The single draw underestimated it by 0.90.9, because ε=0.6\varepsilon=0.6 moved the code above its mean; an ε\varepsilon of −0.6-0.6 would have overestimated it by the same amount.

    Both one-draw derivatives point uphill. An unbiased estimate need not be close; it needs only to be right on average, which is all stochastic gradient ascent requires.

    Draws on