Andy Jones
The “log-derivative trick” is really just a simple application of the chain rule. However, it allows us to rewrite expectations in a way that is amenable to Monte Carlo approximation. Suppose we have a function p ( x ; θ ) 𝑝 ( 𝑥 ; 𝜃 ) (in this context we’ll mostly think of p 𝑝 as a probability density), and we’d like to take the gradient of its logarithm with respect to θ 𝜃 , By a simple application of the chain rule, we have which, rearranging, implies that In many statistical applications, we want to estimate the gradient of an expectation of a function f 𝑓 : To learn more about a few applications where this gradient estimation problem shows up, as well as more modern methods for solving it, I’d recommend this review by Shakir Mohamed et al. Unfortunately, we cannot directly approximate this expression with naive Monte Carlo methods. This is because the expression isn’t in general an expectation. Expanding the expectation we have: ∇ θ E p ( x ; θ ) [ f ( x ) ] = ∇ θ ∫ p
The “log-derivative trick” is really just a simple application of the chain rule. However, it allows us to rewrite expectations in a way that is amenable to Monte Carlo approximation. Log-derivative trick Suppose we have a function $p(x; \theta)$ (in this context we’ll mostly think of $p$ as a probability density), and we’d like to take the gradient of its logarithm with respect to $\theta$, \[\nabla_\theta \log p(x; \theta).\] By a simple application of the chain rule, we have \[\nabla_\theta \log p(x; \theta) = \frac{\nabla_\theta p(x; \theta)}{p(x; \theta)}\] which, rearranging,…
saved by
related reading
- Approximating KL Divergencejoschu.net
- Six (and a half) intuitions for KL divergence — LessWronglesswrong.com
- The Reparameterization Trickgregorygundersen.com
- Policy Gradients Part 1: The REINFORCE Estimatorfa.bianp.net
- Importance Sampling Explained | Built Inbuiltin.com
- A Simplified Overview of Langevin Dynamicsfriedmanroy.github.io
- score matching (hyvarinen)jmlr.org
- Differentiable Programming from Scratchthenumb.at
- Sampling: Two Basic Algorithmsgregorygundersen.com
- Generative Modeling by Estimating Gradients of the Data Distribution | Yang Songyang-song.github.io
- Coordinate Ascent Mean-field Variational Inference (Univariate Gaussian Example)suzyahyah.github.io
- Maximum Likelihood, Fisher Information, Cramer Rao Inequalityomkar-ranadive.github.io