✳flΓ’neur β€” a map of the web's best reading

Approximating KL Divergence

joschu.net Β· 1,073 words Β· saved by 9 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

Approximating KL Divergence John Schulman's Homepage Approximating KL Divergence Posted on 2020/03/07 ← back to blog index \gdef\ratio{\tfrac{p(x)}{q(x)}} \gdef\iratio{\tfrac{q(x)}{p(x)}} \gdef\half{\tfrac{1}{2}} \gdef{\klqp}{\mathrm{KL}[q,p]} \gdef{\klpq}{\mathrm{KL}[p,q]} This post is about Monte-Carlo approximations of KL divergence. KL[q, p] = \sum_x q(x) \log \iratio = E_{ x \sim q}[\log \iratio ] It explains a trick I’ve used in various code, where I approximate \klqp as a sample average of \half (\log p(x) - \log q(x))^2 , for samples x from q , rather the more standard \log \frac{q(x)}

Explore this link on the map β†’

saved by

related reading