netket.callbacks.EarlyStopping#

class netket.callbacks.EarlyStopping[source]#

Bases: Pytree

A simple callback to stop NetKet if there are no more improvements in the training. based on driver._loss_name.

Inheritance
Inheritance diagram of netket.callbacks.EarlyStopping
__init__(min_delta=0.0, min_reldelta=0.0, patience=0, baseline=None, monitor='mean')[source]#

Construct an early stopping callback.

Parameters:
  • min_delta (float) – Minimum change in the monitored quantity to qualify as an improvement.

  • min_reldelta (float) – Minimum relative change in the monitored quantity to qualify as an improvement.

  • patience (Union[int, float]) – Number of epochs with no improvement after which training will be stopped.

  • baseline (Optional[float]) – Baseline value for the monitored quantity. Training will stop if the driver hits the baseline.

  • monitor (str) – Loss statistic to monitor. Should be one of mean, variance, sigma.

Attributes
min_delta: float#

Minimum change in the monitored quantity to qualify as an improvement.

min_reldelta: float#

Minimum relative change in the monitored quantity to qualify as an improvement.

This behaves similarly to min_delta but is more useful for intensive quantities that converge to 0, where absolute tolerances might not be effective.

patience: Union[int, float]#

Number of epochs with no improvement after which training will be stopped.

baseline: Optional[float]#

Baseline value for the monitored quantity. Training will stop if the driver hits the baseline.

monitor: str#

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

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)#

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)