Package ai.djl.training.listener
Class EarlyStoppingListener.Builder
- java.lang.Object
-
- ai.djl.training.listener.EarlyStoppingListener.Builder
-
- Enclosing class:
- EarlyStoppingListener
public static final class EarlyStoppingListener.Builder extends java.lang.ObjectA builder for aEarlyStoppingListener.
-
-
Constructor Summary
Constructors Constructor Description Builder()Constructs aEarlyStoppingListener.Builderwith default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EarlyStoppingListenerbuild()Builds aEarlyStoppingListenerwith the specified values.EarlyStoppingListener.BuilderoptEarlyStopPctImprovement(double earlyStopPctImprovement)Consider early stopping if not x% improvement, defaults to 0.EarlyStoppingListener.BuilderoptEpochPatience(int epochPatience)Stop if insufficient improvement for x epochs in a row, defaults to 0.EarlyStoppingListener.BuilderoptMaxDuration(java.time.Duration duration)Set the maximum duration a training run should take, defaults to Long.MAX_VALUE in ms.EarlyStoppingListener.BuilderoptMaxMillis(int maxMillis)Set the maximum # milliseconds a training run should take, defaults to Long.MAX_VALUE.EarlyStoppingListener.BuilderoptMinEpochs(int minEpochs)Set the minimum # epochs, defaults to 0.
-
-
-
Constructor Detail
-
Builder
public Builder()
Constructs aEarlyStoppingListener.Builderwith default values.
-
-
Method Detail
-
optMinEpochs
public EarlyStoppingListener.Builder optMinEpochs(int minEpochs)
Set the minimum # epochs, defaults to 0.- Parameters:
minEpochs- the minimum # epochs- Returns:
- this builder
-
optMaxDuration
public EarlyStoppingListener.Builder optMaxDuration(java.time.Duration duration)
Set the maximum duration a training run should take, defaults to Long.MAX_VALUE in ms.- Parameters:
duration- the maximum duration a training run should take- Returns:
- this builder
-
optMaxMillis
public EarlyStoppingListener.Builder optMaxMillis(int maxMillis)
Set the maximum # milliseconds a training run should take, defaults to Long.MAX_VALUE.- Parameters:
maxMillis- the maximum # milliseconds a training run should take- Returns:
- this builder
-
optEarlyStopPctImprovement
public EarlyStoppingListener.Builder optEarlyStopPctImprovement(double earlyStopPctImprovement)
Consider early stopping if not x% improvement, defaults to 0.- Parameters:
earlyStopPctImprovement- the percentage improvement to consider early stopping, must be between 0 and 100.- Returns:
- this builder
-
optEpochPatience
public EarlyStoppingListener.Builder optEpochPatience(int epochPatience)
Stop if insufficient improvement for x epochs in a row, defaults to 0.- Parameters:
epochPatience- the number of epochs without improvement to consider stopping, must be greater than 0.- Returns:
- this builder
-
build
public EarlyStoppingListener build()
Builds aEarlyStoppingListenerwith the specified values.- Returns:
- a new
EarlyStoppingListener
-
-