Skip to content

Log-Derivative Trick

Ok this one is a quick one. I am going to mainly use this page just to refer to it when going over Likelihood Ratio Trick and sampling being non-differentiable.

Suppose we want to take the derivative of logpθ(x)log p_{\theta}(x) with respect to θ\theta. Let’ go to high school for a second.

θlog pθ(x)=θpθ(x) . 1pθ(x)\nabla_{\theta} \log \ p_{\theta}(x) = \nabla_{\theta} p_{\theta}(x) \ . \ \frac{1}{p_{\theta}(x)}

Just rearrange the terms and we are done:

θpθ(x)=pθ(x) θlog pθ(x)\nabla_{\theta} p_{\theta}(x) = p_{\theta}(x) \ \nabla_{\theta} \log \ p_{\theta}(x)

Just remamber the last equation. We will use it a lot.


Previous Post
Softmaxing is actually Utility Maximization
Next Post
Gumbel-Max Trick