MarginalLikelihood
MarginalLikelihood(n_steps=100, lr=1.0, sigma_init=None)Maximize the Laplace marginal likelihood of the fit data. The default tuner.
It tunes the prior precision and the likelihood’s learned hyperparameters (the sigma of lk.Gaussian()) together, with L-BFGS on their logs. laplace-torch’s optimize_prior_precision(method="marglik") tunes the prior precision alone, with Adam, so the two agree only when sigma is fixed, as in lk.Gaussian(sigma=1.0). The marginal likelihood needs the data fit term, so the data must have targets.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| n_steps | int | Cap on the L-BFGS iterations. | 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 (1 after lk.laplace). |
None |
Methods
| Name | Description |
|---|---|
| check | Check that the data has targets and the prior’s tunable() keeps its rules. |
check
MarginalLikelihood.check(prior, likelihood, batch, /)Check that the data has targets and the prior’s tunable() keeps its rules.
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 |
|---|---|---|
| ValueError | The batch has no targets, so there is no marginal likelihood. | |
| StructureError | The prior’s tunable() breaks its rules. |