Class Checkpoint<T, TInput, TOutput>
Represents a saved checkpoint of model training state.
public class Checkpoint<T, TInput, TOutput>
Type Parameters
TThe numeric data type used for calculations.
TInputTOutput
- Inheritance
-
Checkpoint<T, TInput, TOutput>
- Inherited Members
Remarks
For Beginners: A checkpoint is like a save point in a video game - it captures everything needed to resume training from that exact point.
Constructors
Checkpoint()
Initializes a new instance of the Checkpoint class.
public Checkpoint()
Checkpoint(object, IOptimizer<T, TInput, TOutput>, int, int, Dictionary<string, T>, Dictionary<string, object>?)
Initializes a new instance of the Checkpoint class with an optimizer object.
public Checkpoint(object model, IOptimizer<T, TInput, TOutput> optimizer, int epoch, int step, Dictionary<string, T> metrics, Dictionary<string, object>? metadata = null)
Parameters
modelobjectThe model to save.
optimizerIOptimizer<T, TInput, TOutput>The optimizer to extract state from.
epochintThe current epoch.
stepintThe current step.
metricsDictionary<string, T>Performance metrics at this checkpoint.
metadataDictionary<string, object>Additional metadata.
Checkpoint(object, Dictionary<string, object>, string?, int, int, Dictionary<string, T>, Dictionary<string, object>?)
Initializes a new instance of the Checkpoint class with specified values.
public Checkpoint(object model, Dictionary<string, object> optimizerState, string? optimizerTypeName, int epoch, int step, Dictionary<string, T> metrics, Dictionary<string, object>? metadata = null)
Parameters
modelobjectThe model to save.
optimizerStateDictionary<string, object>The optimizer state dictionary.
optimizerTypeNamestringThe optimizer type name for reconstruction.
epochintThe current epoch.
stepintThe current step.
metricsDictionary<string, T>Performance metrics at this checkpoint.
metadataDictionary<string, object>Additional metadata.
Properties
CheckpointId
Gets the unique identifier for this checkpoint.
public string CheckpointId { get; }
Property Value
CreatedAt
Gets the timestamp when this checkpoint was created.
public DateTime CreatedAt { get; }
Property Value
Epoch
Gets or sets the training epoch number.
public int Epoch { get; set; }
Property Value
FilePath
Gets or sets the file path where the checkpoint is stored.
public string? FilePath { get; set; }
Property Value
Metadata
Gets or sets additional metadata.
public Dictionary<string, object> Metadata { get; set; }
Property Value
Metrics
Gets or sets the performance metrics at this checkpoint.
public Dictionary<string, T> Metrics { get; set; }
Property Value
- Dictionary<string, T>
Model
Gets or sets the model at this checkpoint. Note: The model is stored as object for serialization compatibility.
public object? Model { get; set; }
Property Value
OptimizerState
Gets or sets the optimizer state as a serializable dictionary.
public Dictionary<string, object> OptimizerState { get; set; }
Property Value
Remarks
For Beginners: Instead of storing the optimizer object directly (which can cause serialization issues with interfaces), we store its state as a dictionary. The optimizer can be reconstructed from this state when loading the checkpoint.
Key values typically include:
- "LearningRate": The current learning rate
- "OptimizerType": The type name of the optimizer
- "Parameters": Any additional optimizer-specific parameters
OptimizerTypeName
Gets or sets the optimizer type name for reconstruction.
public string? OptimizerTypeName { get; set; }
Property Value
Step
Gets or sets the training step number.
public int Step { get; set; }