netket.callbacks.StopRun#
- exception netket.callbacks.StopRun[source]#
Exception to be raised by callbacks to gracefully stop the optimisation loop.
Raise this exception (or a subclass of it) from any callback hook to stop the
run()loop early. The driver will catch it, callon_run_end()on all callbacks, and then return normally — no traceback is printed and no exception propagates to the caller.The message passed to the exception will be printed to stdout.
Example:
class StopAfterConvergence(nk.callbacks.AbstractCallback): def on_step_end(self, step, log_data, driver): if log_data["Energy"].error_of_mean < 1e-4: raise nk.callbacks.StopRun("Energy converged.")
- __init__(*args, **kwargs)#