LBFGS#
- class liesel.optim.LBFGS(position_keys, optimizer=(<function chain.<locals>.init_fn>, <function chain.<locals>.update_fn>), identifier='', activate_after_epochs=0)[source]#
Bases:
OptimizerOptimizer wrapper using Optax L-BFGS.
LBFGSbehaves likeOptimizerbut usesoptax.value_and_grad_from_state()insidestep(), which lets Optax reuse value/gradient information stored by the L-BFGS transformation.L-BFGS requires full-data batches, a deterministic objective, and must be the sole optimizer. Other parameter updates would invalidate its cached objective and curvature history. Use one joint L-BFGS for all selected parameters; unselected parameters stay fixed. The engine rejects mini-batches and mixed optimizer configurations, but cannot detect stochastic objective evaluations. For a deterministic objective, the returned scalar is the value used for the update at the supplied pre-update position.
- Parameters:
position_keys (
Sequence[str]) – Names of the parameter entries owned by this optimizer.optimizer (
GradientTransformationExtraArgs, default:GradientTransformationExtraArgs(init=<function chain.<locals>.init_fn at 0x7524f0cb6340>, update=<function chain.<locals>.update_fn at 0x7524f0cb63e0>)) – Optax L-BFGS transformation. Defaults tooptax.lbfgs().identifier (
str, default:'') – Optional optimizer-state identifier filled byOptimEnginewhen omitted.activate_after_epochs (
int, default:0) – Number of completed epochs required before this optimizer participates in batch updates.0activates it from the first epoch.
Examples
>>> from liesel.optim import LBFGS >>> lbfgs = LBFGS(["loc"], identifier="loc_lbfgs") >>> lbfgs.position_keys ('loc',) >>> lbfgs.identifier 'loc_lbfgs' >>> repr(lbfgs) "LBFGS(('loc',), identifier=loc_lbfgs)"
Methods
step(position, loss, carry)Runs one L-BFGS optimizer step on
position.Attributes
Optional optimizer-state identifier filled by
OptimEnginewhen omitted.Optax L-BFGS transformation.
Names of the parameter entries owned by this optimizer.