Skip to main content

core.fit_curvature

core.fit_curvature(
    model,
    likelihood,
    params,
    hessian_approx,
    /,
    *,
    generator=None,
    capabilities=None,
)

Bind a model, likelihood, params and curvature method for fitting.

The likelihood needs of the method (each per-block member) are always checked, and those of each pass when it starts.

Parameters

Name Type Description Default
model ModelFn The model as a function of the params. required
likelihood Likelihood The likelihood. required
params Params The params the curvature is taken at. required
hessian_approx Any A single-pass Curvature or a multi-pass Staged method. required
generator torch.Generator | None Seeds the fit. One seed is drawn from it, or from torch’s global RNG when None, so torch.manual_seed makes the fit repeatable. Each batch’s update gets a fresh generator derived from that seed, the pass number and the examples seen before the batch. None
capabilities Capabilities | None The probed capabilities. None skips the model checks. None

Returns

Name Type Description
Any A CurvatureFit for a Curvature, a StagedCurvatureFit for a Staged method.

Raises

Name Type Description
CapabilityError The likelihood lacks something the method needs, or capabilities was probed for parameters that don’t cover params.