testing.check_likelihood
testing.check_likelihood(likelihood, f, y, /)Check a likelihood’s laws at outputs f and targets y (one batch).
Not core.check_likelihood, which checks that a likelihood has the hooks a method’s Requirements ask for.
- It satisfies
Likelihood, andcore.log_probis shaped[N], one value per example. HasDistribution:distribution(f).log_prob(y), summed over each example’s positions, equalscore.log_prob.LateLikelihood:unit()returns self unless it drops a hyperparameter, that is, unless some leaf of the likelihood (by identity) is not a leaf ofunit(); and, whenunit()is itself aLateLikelihood,unit().unit()isunit().HasOutputHessian: with \(H\) =dense(), \(H\) is shaped[N, E, E], \(\mathrm{mv}(v) = H v\) for a random \(v\), \(H = H^\top\), and \(H\) is positive semi-definite: its smallest eigenvalue is at least \(-\mathrm{RTOL} \cdot \max |H|\). These run only for events up toMAX_DENSE_EVENTentries and a tensorf.
Masks are not applied: log_prob is compared over every position. Equalities hold up to RTOL. Errors that the likelihood raises propagate, except a StructureError from core.log_prob, which fails the shape law.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| likelihood | Likelihood | The likelihood. | required |
| f | Outputs | Model outputs for one batch. Pass float64 so that RTOL holds. |
required |
| y | Targets | Targets for the same batch. | required |
Raises
| Name | Type | Description |
|---|---|---|
| AssertionError | A law above fails. The message names the law and likelihood. |