Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-260

Bits per Dimension

Problem

Return the bits-per-dimension score of a generative model from its total negative log-likelihood in nats:

BPD = nll_nats / (num_samples * dims * ln(2))

Hint

Dividing by ln(2) converts nats into bits.

Test cases

case 1
in: [1000,10,100]
expected: 1.4426950408889636
case 2
in: [693.1471805599454,10,100]
expected: 1.0000000000000002
case 3
in: [0,5,10]
expected: 0
case 4
in: [100,4,25]
expected: 1.4426950408889634
Starter codePython
import math
def bits_per_dimension(nll_nats, num_samples, dims):
    # Your code here
    pass

4 test cases · run your code against them in the editor