CheckpointManager<T, TInput, TOutput>
Models & Types · AiDotNet.CheckpointManagement
Implementation of checkpoint management for saving and restoring training state.
Inheritance: CheckpointManagerBase<T, TInput, TOutput> → CheckpointManager<T, TInput, TOutput>
How It Works
For Beginners: This manages checkpoints (save points) of your model training, allowing you to save progress, resume training, and keep track of the best models.
Constructors
| Constructor | Summary |
|---|---|
CheckpointManager(string checkpointDirectory) |
Initializes a new instance of the CheckpointManager class. |
Methods
| Method | Summary |
|---|---|
Checkpoint<T, TInput, TOutput> LoadBestCheckpoint(string metricName, MetricOptimizationDirection direction) |
Loads the checkpoint with the best metric value. |
Checkpoint<T, TInput, TOutput> LoadCheckpoint(string checkpointId) |
Loads a checkpoint and restores the training state. |
Checkpoint<T, TInput, TOutput> LoadLatestCheckpoint() |
Loads the most recent checkpoint. |
List<CheckpointMetadata<T>> ListCheckpoints(string sortBy, bool descending) |
Lists all available checkpoints. |
bool RestoreLatestModelState(ICheckpointableModel target) |
Restores the most recent checkpoint’s saved model state into target. |
bool RestoreModelState(string checkpointId, ICheckpointableModel target) |
Restores a checkpoint’s saved model state into target — a live model of the matching type — via the ICheckpointableModel contract. |
int CleanupKeepBest(string metricName, int keepBest, MetricOptimizationDirection direction) |
Deletes checkpoints except the best N according to a metric. |
int CleanupOldCheckpoints(int keepLast) |
Deletes old checkpoints, keeping only the most recent ones. |
string SaveCheckpoint(IModel<TInput, TOutput, TMetadata> model, IOptimizer<T, TInput, TOutput> optimizer, int epoch, int step, Dictionary<string, T> metrics, Dictionary<string, object> metadata) |
Saves a checkpoint of the current training state. |
string TryAutoSaveCheckpoint(IModel<TInput, TOutput, TMetadata> model, IOptimizer<T, TInput, TOutput> optimizer, int epoch, int step, Dictionary<string, T> metrics, double? metricValue, bool shouldMinimize, Dictionary<string, object> metadata) |
Attempts to save a checkpoint automatically based on configured auto-checkpoint settings. |
void DeleteCheckpoint(string checkpointId) |
Deletes a specific checkpoint. |