Class EarlyStoppingListener.Builder

java.lang.Object
ai.djl.training.listener.EarlyStoppingListener.Builder
Enclosing class:
EarlyStoppingListener

public static final class EarlyStoppingListener.Builder extends Object
A builder for a EarlyStoppingListener.
  • Constructor Details

  • Method Details

    • 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(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 a EarlyStoppingListener with the specified values.
      Returns:
      a new EarlyStoppingListener