diagnostics.assess_advi_convergence()
Judge whether an ADVI fit had stopped improving by its end.
Usage
diagnostics.assess_advi_convergence(
loss_history, tolerance=1.0, window_fraction=0.05
)Compares the mean loss (negative ELBO, in nats) over the final window_fraction of iterations with the mean over the window of the same length just before it. The fit is treated as converged when the loss fell by no more than tolerance nats between the two windows and the windows are long enough to measure that: the standard error of the difference must also be within tolerance. A short or very noisy run therefore never counts as converged.
Parameters
loss_history: npt.NDArray[np.float64]-
Loss at each iteration.
tolerance: float = 1.0-
Largest fall in mean loss, in nats, between the two final windows that still counts as converged.
window_fraction: float = 0.05-
Fraction of iterations in each window.
Returns
dict: dict-
With keys
converged(bool),final_loss(mean loss in the final window),improvement(fall in mean loss between the two windows; positive means still improving),standard_error(of that fall),window(iterations per window) andn_iterations.