All problems
Bits-Back Coding
Problem
Return the total description length in bits of a bits-back code:
length = nll_bits + kl_bits
where nll_bits is the negative log-likelihood and kl_bits the KL divergence from the posterior to the prior.
Hint
A tighter posterior (smaller KL) shortens the code.
Test cases
case 1
in: [10,2]
expected: 12
case 2
in: [0,0]
expected: 0
case 3
in: [5.5,1.5]
expected: 7
case 4
in: [3,0]
expected: 3
Starter codePython
def bits_back_coding(nll_bits, kl_bits):
# Your code here
pass4 test cases · run your code against them in the editor