Get log-Likelihood

Hi,

I am trying to get the log-likelihood for my model:

def model(data):
    x = numpyro.sample("x", dist.Uniform(low=-2, high=2), sample_shape=(10,))
    img_estimated = some_function(x)

    with numpyro.plate("data", size=data.shape[0]):
        obs_image = numpyro.sample(
            "obs",
            dist.TruncatedNormal(
                loc=img_estimated, scale=measurement_std, low=0, high=1
            ),
            obs=data,
        )

What’s the easiest way to go about this?

Thanks,
Atharva

@atharvahans you can use the helper function numpyro.infer.util.log_likelihood.

1 Like