quantlab.model.torch_training.TrainLossThreshold#
- class quantlab.model.torch_training.TrainLossThreshold(threshold, max_epochs)[source]#
Bases:
objectMASTER’s stopping rule, for a head’s stop hooks.
updatereturns True once an epoch’s training loss is at or belowthreshold, or aftermax_epochsepochs; the head keeps the last weights either way. The object counts the epochs of one fit: build a fresh one in_on_fit_start.- Parameters:
- thresholdfloat
Training loss to reach.
- max_epochsint
Epoch cap; at least 1. Training never runs past the
epochshyperparameter anyway.
- Raises:
- ValueError
If
max_epochsis below 1.
Examples
>>> rule = TrainLossThreshold(threshold=0.95, max_epochs=40) >>> [rule.update(loss) for loss in (1.2, 1.0, 0.9)] [False, False, True]