Class CheckpointListener.Builder
- java.lang.Object
-
- org.nd4j.autodiff.listeners.checkpoint.CheckpointListener.Builder
-
- Enclosing class:
- CheckpointListener
public static class CheckpointListener.Builder extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CheckpointListenerbuild()CheckpointListener.BuilderdeleteExisting(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!CheckpointListener.BuilderfileNamePrefix(String fileNamePrefix)CheckpointListener.BuilderkeepAll()Keep all model checkpoints - i.e., don't delete any.CheckpointListener.BuilderkeepLast(int n)Keep only the last N most recent model checkpoint files.CheckpointListener.BuilderkeepLastAndEvery(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).CheckpointListener.BuilderlogSaving(boolean logSaving)If true (the default) log a message every time a model is savedCheckpointListener.BuildersaveEvery(long amount, TimeUnit timeUnit)Save a model periodicallyCheckpointListener.BuildersaveEvery(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)CheckpointListener.BuildersaveEveryEpoch()Save a model at the end of every epochCheckpointListener.BuildersaveEveryNEpochs(int n)Save a model at the end of every N epochsCheckpointListener.BuildersaveEveryNIterations(int n)Save a model every N iterationsCheckpointListener.BuildersaveEveryNIterations(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)CheckpointListener.BuildersaveUpdaterState(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.
-
-
-
Method Detail
-
fileNamePrefix
public CheckpointListener.Builder fileNamePrefix(String fileNamePrefix)
-
saveEveryEpoch
public CheckpointListener.Builder saveEveryEpoch()
Save a model at the end of every epoch
-
saveEveryNEpochs
public CheckpointListener.Builder saveEveryNEpochs(int n)
Save a model at the end of every N epochs
-
saveEveryNIterations
public CheckpointListener.Builder saveEveryNIterations(int n)
Save a model every N iterations
-
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 unittimeUnit- 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 unittimeUnit- 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 keepeveryN- 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!
-
build
public CheckpointListener build()
-
-