All problems
Variational Bound Tightness
Problem
Return the gap between the log evidence and the evidence lower bound:
gap = log_evidence - elbo
The gap equals the KL divergence from the variational posterior to the true posterior, so the bound is tight exactly when the gap is zero.
Hint
The ELBO is always at most the log evidence for any variational family.
Test cases
case 1
in: [10,9]
expected: 1
case 2
in: [0,0]
expected: 0
case 3
in: [-5,-7]
expected: 2
case 4
in: [3.5,3.5]
expected: 0
Starter codePython
def elbo_gap(log_evidence, elbo):
# Your code here
pass4 test cases · run your code against them in the editor