core.StagedCurvatureFit
core.StagedCurvatureFit(
model=static(),
likelihood=static(),
params,
curvature=static(),
caps=None,
*,
_seed=_Seed.draw(),
)A model, likelihood, params and multi-pass method bound for fitting.
Only start(): the number of passes is the method’s business. Build it with fit_curvature, which checks the likelihood.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model | ModelFn | The model as a function of the params. | static() |
| likelihood | Likelihood | The likelihood. The method sees its unit version (see LateLikelihood). |
static() |
| params | Params | The params the curvature is taken at. | required |
| curvature | Staged[R] | The multi-pass method. | static() |
| caps | Capabilities | None | The probed capabilities. None skips the model checks. |
None |
Attributes
| Name | Description |
|---|---|
| ctx | The context the method sees, with the unit likelihood. |
Methods
| Name | Description |
|---|---|
| posterior | Build the posterior without repeating the model, likelihood, and layout. |
| start | The first pass of the method’s plan. |
posterior
core.StagedCurvatureFit.posterior(curvature, /, prior, n_data)Build the posterior without repeating the model, likelihood, and layout.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| curvature | Op | The finalized curvature, the per-example average. | required |
| prior | Pr | The prior. Its location must match the params. | required |
| n_data | Tensor | The effective data size \(N\) the curvature is multiplied by. | required |
Returns
| Name | Type | Description |
|---|---|---|
| LaplacePosterior[Op, Pr] | The Laplace posterior at the fit’s params. |
Raises
| Name | Type | Description |
|---|---|---|
| StructureError | The prior’s location doesn’t match the params, or the curvature can’t absorb the prior precision (e.g. KFAC on KFAC). |
start
core.StagedCurvatureFit.start()The first pass of the method’s plan.
Returns
| Name | Type | Description |
|---|---|---|
| Running[R] | A Running step. Its finish gives the next pass, or Finished after the last. |
Raises
| Name | Type | Description |
|---|---|---|
| CapabilityError | The method’s plan refuses the fit, with or without caps. With caps, also when the capabilities lack something the method needs. |
|
| StructureError | The method’s plan refuses the params or layout. |