Where does the constant term $+1$ go when simplifying this integral in eq (2)?

61 Views Asked by At

I've been looking at this breakdown that deals with taking the gradient of an expectation w.r.t the distribution the expectation is sampling from. On equation 2 is where I get stuck. Where does the $+1$ on the RHS of eq (2) go? I was/am expecting it to be: $\int{ (\log p_\theta(y) - \log q_\phi(x) +1 ) \nabla_{\phi} q_\phi(x) dz }$.

I've my answer and should add that both $p(x,z)$ and $q_\phi (z|x)$ are probabilities. By integrating over one (to get 1), then taking the gradient (to get 0), my $+1$ dissapears.

$$\begin{align} \nabla_{\phi} E_{q_\phi(z|x)} \left [ \log p(x, z) - \log q_\phi(z|x) \right] &= \nabla_{\phi} \int{\log p(x, z) q_\phi(z|x) dz} -\nabla_{\phi} \int{q_\phi(z|x) \log q_\phi(z|x) dz } \tag{1}\\ &=\int{\log p(x, z) \nabla_{\phi} q_\phi(z|x) dz} - \int{(\log q_\phi(z|x) +1) \nabla_{\phi} q_\phi(z|x) dz } \tag{2}\\ &= \int{ (\log p(x, z) - \log q_\phi(z|x) ) \nabla_{\phi} q_\phi(z|x) dz } \tag{3} \end{align}$$