Skip to main content

testing.check_objective

testing.check_objective(objective, posterior)

Check a tuning objective against the core contracts.

The objective is called on a copy of posterior whose leaves are detached and whose hyperparameters \(\phi_i\) (lk.core.hyperparameters, what lk.Minimize tunes) require grad.

  • It returns a 0-dim tensor \(L\), and \(L\) is finite.
  • It is differentiable with respect to every hyperparameter: each \(\partial L / \partial \phi_i\) exists and is finite.

posterior is not changed. Errors that the objective raises propagate.

Parameters

Name Type Description Default
objective Objective[P] The tuning objective. required
posterior P The posterior to evaluate it at. required

Raises

Name Type Description
AssertionError A law above fails. The message names the law and objective.
ValueError The posterior has no hyperparameters.