netket.callbacks.InvalidLossStopping#

class netket.callbacks.InvalidLossStopping[source]#

Bases: Pytree

A simple callback to stop the optimisation when the monitored quantity becomes invalid for at least patience steps.

Inheritance
Inheritance diagram of netket.callbacks.InvalidLossStopping
__init__(monitor='mean', patience=0)[source]#

Construct a callback stopping the optimisation when the monitored quantity becomes invalid for at least patience steps.

Parameters:
  • monitor (str) – a string with the name of the quantity to be monitored. This is applied to the standard loss optimised by a driver, such as the Energy for the VMC driver. Should be one of ‘mean’, ‘variance’, ‘error_of_mean’ (default: ‘mean’).

  • patience (int | float) – Number of steps to wait before stopping the execution after the tracked quantity becomes invalid (default 0, meaning that it stops immediately).

Attributes
monitor: str#

Loss statistic to monitor. Should be one of ‘mean’, ‘variance’, ‘error_of_mean’.

patience: int | float#

Number of epochs with invalid loss after which training will be stopped.

Methods
__call__(step, log_data, driver)[source]#

A boolean function that determines whether or not to stop training.

Parameters:
  • step – An integer corresponding to the step (iteration or epoch) in training.

  • log_data – A dictionary containing log data for training.

  • driver – A NetKet variational driver.

Returns:

A boolean. If True, training continues, else, it does not.

replace(**kwargs)[source]#

Replace the values of the fields of the object with the values of the keyword arguments. If the object is a dataclass, dataclasses.replace will be used. Otherwise, a new object will be created with the same type as the original object.

Return type:

TypeVar(P, bound= Pytree)

Parameters:
  • self (P)

  • kwargs (Any)