Skip to main content

Minimize

Minimize(objective=static(), n_steps=100, lr=1.0, sigma_init=None)

Minimize an objective over every hyperparameter, with L-BFGS on their logs.

It tunes the prior precision and the likelihood’s learned hyperparameters jointly, and keeps them positive. The objective needs a gradient with respect to them; use GridSearch for one without (such as lk.objectives.ece).

post = lk.tune(post, lk.Minimize(lk.objectives.predictive_nll(val_loader)))

Parameters

Name Type Description Default
objective Objective[Any] The loss over a posterior, lower is better. static()
n_steps int Cap on the L-BFGS iterations. L-BFGS stops earlier once the gradient or the change in the logs is negligible. 100
lr float Initial step of the strong-Wolfe line search each iteration runs. 1.0
sigma_init float | None Where a learned sigma (lk.Gaussian()) starts, as laplace-torch’s sigma_noise_init. None keeps its current value. None

Methods

Name Description
check Check the prior’s tunable() before the fit.

check

Minimize.check(prior, likelihood, batch, /)

Check the prior’s tunable() before the fit.

Parameters

Name Type Description Default
prior Prior The prior of the fit. required
likelihood Likelihood The likelihood of the fit. required
batch Batch The first batch of the data. required

Raises

Name Type Description
StructureError The prior’s tunable() breaks its rules, or there is nothing to tune: the prior is not a TunablePrior and the likelihood learns nothing.