flΓ’neur

Approximating KL Divergence

web.archive.org Β· saved by 1 readers

This post is about Monte-Carlo approximations of KL divergence. 𝐾 𝐿 [ π‘ž , 𝑝 ] = βˆ‘ π‘₯ π‘ž ( π‘₯ ) log ⁑ π‘ž ( π‘₯ ) 𝑝 ( π‘₯ ) = 𝐸 π‘₯ ∼ π‘ž [ log ⁑ π‘ž ( π‘₯ ) 𝑝 ( π‘₯ ) ] KL[q,p]= x βˆ‘ ​ q(x)log p(x) q(x) ​ =E x∼q ​ [log p(x) q(x) ​ ] It explains a trick I’ve used in various code, where I approximate K L [ π‘ž , 𝑝 ] KL[q,p] as a sample average of 1 2 ( log ⁑ 𝑝 ( π‘₯ ) βˆ’ log ⁑ π‘ž ( π‘₯ ) ) 2 2 1 ​ (logp(x)βˆ’logq(x)) 2 , for samples π‘₯ x from π‘ž q, rather the more standard log ⁑ π‘ž ( π‘₯ ) 𝑝 ( π‘₯ ) log p(x) q(x) ​ . This post will explain why this expression is a good (though biased) estimator of KL, and how to make it unbiased while preserving its low variance. Our options for computing KL depend on what kind of access we have to 𝑝 p and π‘ž q. Here, we’ll be assuming that we can compute the probabilities (or probability densities) 𝑝 ( π‘₯ ) p(x) and π‘ž ( π‘₯ ) q(x) for any π‘₯ x, but we can’t calculate the sum over π‘₯ x analytically. Why wouldn’t we be able to calculate

saved by