Class CheckpointListener.Builder

    • Constructor Detail

      • Builder

        public Builder​(@NonNull
                       @NonNull String rootDir)
        Parameters:
        rootDir - Root directory to save models to
      • Builder

        public Builder​(@NonNull
                       @NonNull File rootDir)
        Parameters:
        rootDir - Root directory to save models to
    • Method Detail

      • saveEveryNIterations

        public CheckpointListener.Builder saveEveryNIterations​(int n,
                                                               boolean sinceLast)
        Save a model every N iterations (if sinceLast == false), or if N iterations have passed since the last model vas saved (if sinceLast == true)
      • saveEvery

        public CheckpointListener.Builder saveEvery​(long amount,
                                                    TimeUnit timeUnit)
        Save a model periodically
        Parameters:
        amount - Quantity of the specified time unit
        timeUnit - Time unit
      • saveEvery

        public CheckpointListener.Builder saveEvery​(long amount,
                                                    TimeUnit timeUnit,
                                                    boolean sinceLast)
        Save a model periodically (if sinceLast == false), or if the specified amount of time has elapsed since the last model was saved (if sinceLast == true)
        Parameters:
        amount - Quantity of the specified time unit
        timeUnit - Time unit
      • keepAll

        public CheckpointListener.Builder keepAll()
        Keep all model checkpoints - i.e., don't delete any. Note that this is the default.
      • keepLast

        public CheckpointListener.Builder keepLast​(int n)
        Keep only the last N most recent model checkpoint files. Older checkpoints will automatically be deleted.
        Parameters:
        n - Number of most recent checkpoints to keep
      • keepLastAndEvery

        public CheckpointListener.Builder keepLastAndEvery​(int nLast,
                                                           int everyN)
        Keep the last N most recent model checkpoint files, and every M checkpoint files.
        For example: suppose you save every 100 iterations, for 2050 iteration, and use keepLastAndEvery(3,5). This means after 2050 iterations you would have saved 20 checkpoints - some of which will be deleted. Those remaining in this example: iterations 500, 1000, 1500, 1800, 1900, 2000.
        Parameters:
        nLast - Most recent checkpoints to keep
        everyN - Every N checkpoints to keep (regardless of age)
      • logSaving

        public CheckpointListener.Builder logSaving​(boolean logSaving)
        If true (the default) log a message every time a model is saved
        Parameters:
        logSaving - Whether checkpoint saves should be logged or not
      • saveUpdaterState

        public CheckpointListener.Builder saveUpdaterState​(boolean saveUpdaterState)
        Whether the updater state (history/state for Adam, Nesterov momentum, etc) should be saved with each checkpoint.
        Updater state is saved by default. If you expect to continue training on any of the checkpoints, this should be set to true. However, it will increase the file size.
        Parameters:
        saveUpdaterState - If true: updater state will be saved with checkpoints. False: not saved.
      • deleteExisting

        public CheckpointListener.Builder deleteExisting​(boolean deleteExisting)
        If the checkpoint listener is set to save to a non-empty directory, should the CheckpointListener-related content be deleted?
        This is disabled by default (and instead, an exception will be thrown if existing data is found)
        WARNING: Be careful when enabling this, as it deletes all saved checkpoint models in the specified directory!