OptimNaNDebugInfo

OptimNaNDebugInfo#

class liesel.optim.OptimNaNDebugInfo(kind, epoch, batch, obs_batch, last_non_nan_position, nan_position, loss, optimizer_index, optimizer_identifier, optimizer_position_keys, reproduction_position, reproduction_carry)[source]#

Bases: object

Reproduction data for the first NaN captured by OptimEngine.

Use reproduce_step() for NaNs introduced by an optimizer update and reproduce_loss() for NaNs returned by an optimizer’s pre-update loss or by the explicit batched loss evaluation when no optimizer is active.

The reported optimizer is where NaN was first detected. An earlier update may have produced finite values outside the model’s valid parameter domain. Inspect last_non_nan_position: it is free of NaNs, but is not necessarily a valid model state.

Methods

optimizer(engine)

Returns the optimizer associated with the captured NaN, if known.

reproduce_loss(engine)

Reproduces the captured pre-update loss.

reproduce_step(engine)

Re-runs the optimizer step that introduced a NaN position.

Attributes

position

Position most directly associated with the captured NaN event.

kind

Stage at which the first NaN was detected.

epoch

Epoch index at which the NaN was detected.

batch

Batch index at which the NaN was detected.

obs_batch

Observed batch used when the NaN was detected.

last_non_nan_position

Last position free of NaNs; it need not be a valid model state.

nan_position

Position containing the detected NaN, if available.

loss

Loss value associated with the captured event, if available.

optimizer_index

Index of the optimizer at detection, if known.

optimizer_identifier

Identifier of the optimizer at detection, if known.

optimizer_position_keys

Position keys handled by the optimizer at detection, if known.

reproduction_position

Parameter position used to reproduce the captured event.

reproduction_carry

Optimizer carry used to reproduce the captured event.