Table of Contents

Class Checkpoint<T, TInput, TOutput>

Namespace
AiDotNet.Models
Assembly
AiDotNet.dll

Represents a saved checkpoint of model training state.

public class Checkpoint<T, TInput, TOutput>

Type Parameters

T

The numeric data type used for calculations.

TInput
TOutput
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

model object

The model to save.

optimizer IOptimizer<T, TInput, TOutput>

The optimizer to extract state from.

epoch int

The current epoch.

step int

The current step.

metrics Dictionary<string, T>

Performance metrics at this checkpoint.

metadata Dictionary<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

model object

The model to save.

optimizerState Dictionary<string, object>

The optimizer state dictionary.

optimizerTypeName string

The optimizer type name for reconstruction.

epoch int

The current epoch.

step int

The current step.

metrics Dictionary<string, T>

Performance metrics at this checkpoint.

metadata Dictionary<string, object>

Additional metadata.

Properties

CheckpointId

Gets the unique identifier for this checkpoint.

public string CheckpointId { get; }

Property Value

string

CreatedAt

Gets the timestamp when this checkpoint was created.

public DateTime CreatedAt { get; }

Property Value

DateTime

Epoch

Gets or sets the training epoch number.

public int Epoch { get; set; }

Property Value

int

FilePath

Gets or sets the file path where the checkpoint is stored.

public string? FilePath { get; set; }

Property Value

string

Metadata

Gets or sets additional metadata.

public Dictionary<string, object> Metadata { get; set; }

Property Value

Dictionary<string, object>

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

object

OptimizerState

Gets or sets the optimizer state as a serializable dictionary.

public Dictionary<string, object> OptimizerState { get; set; }

Property Value

Dictionary<string, object>

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

string

Step

Gets or sets the training step number.

public int Step { get; set; }

Property Value

int