Interface IExperimentRun<T>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
Represents a single training run within an experiment.
public interface IExperimentRun<T>
Type Parameters
TThe numeric data type used for calculations (e.g., float, double).
Remarks
For Beginners: A run represents one attempt at training a model with specific settings. Each run records everything about that training session: what settings you used (parameters), how well it performed (metrics), and what it created (artifacts like the trained model).
Think of a run like a single entry in a lab notebook - it captures all the details of one specific experiment attempt.
Properties
EndTime
Gets the timestamp when the run ended.
DateTime? EndTime { get; }
Property Value
ExperimentId
Gets the experiment ID this run belongs to.
string ExperimentId { get; }
Property Value
RunId
Gets the unique identifier for this run.
string RunId { get; }
Property Value
RunName
Gets or sets the name of this run.
string? RunName { get; set; }
Property Value
StartTime
Gets the timestamp when the run was started.
DateTime StartTime { get; }
Property Value
Status
Gets the current status of the run (Running, Completed, Failed, etc.).
string Status { get; }
Property Value
Tags
Gets the tags associated with this run.
ConcurrentDictionary<string, string> Tags { get; }
Property Value
Remarks
This property returns a thread-safe concurrent dictionary for safe multi-threaded access.
Methods
AddNote(string)
Adds a note or comment to the run.
void AddNote(string note)
Parameters
notestringThe note content.
Complete()
Marks the run as completed successfully.
void Complete()
Fail(string?)
Marks the run as failed with an optional error message.
void Fail(string? errorMessage = null)
Parameters
errorMessagestringDescription of the failure.
GetArtifacts()
Gets all artifacts logged for this run.
List<string> GetArtifacts()
Returns
GetLatestMetric(string)
Gets the latest value for a specific metric.
T? GetLatestMetric(string metricName)
Parameters
metricNamestringThe name of the metric.
Returns
- T
The latest metric value, or null if not found.
GetMetrics()
Gets all metrics logged for this run.
Dictionary<string, List<(int Step, T Value, DateTime Timestamp)>> GetMetrics()
Returns
- Dictionary<string, List<(int Step, T Value, DateTime Timestamp)>>
Dictionary where keys are metric names and values are lists of (step, value, timestamp) tuples.
GetNotes()
Gets all notes added to this run.
List<(DateTime Timestamp, string Note)> GetNotes()
Returns
GetParameters()
Gets all parameters logged for this run.
Dictionary<string, object> GetParameters()
Returns
- Dictionary<string, object>
Dictionary of parameter names and values.
LogArtifact(string, string?)
Logs an artifact (file) associated with this run.
void LogArtifact(string localPath, string? artifactPath = null)
Parameters
localPathstringPath to the file to log.
artifactPathstringOptional path within the artifact store.
Remarks
For Beginners: Artifacts are files produced during training, like:
- Saved models
- Training plots/visualizations
- Configuration files
- Log files
LogArtifacts(string, string?)
Logs a directory of artifacts.
void LogArtifacts(string localDir, string? artifactPath = null)
Parameters
localDirstringPath to the directory to log.
artifactPathstringOptional path within the artifact store.
LogMetric(string, T, int, DateTime?)
Logs a metric value at a specific step/iteration.
void LogMetric(string key, T value, int step = 0, DateTime? timestamp = null)
Parameters
keystringThe metric name (e.g., "loss", "accuracy").
valueTThe metric value.
stepintThe training step/iteration number.
timestampDateTime?Optional timestamp for the metric.
Remarks
For Beginners: Metrics are measurements of how well your model is performing, like accuracy or loss. Unlike parameters, metrics change over time as the model trains. The step parameter lets you track how the metric changes over iterations.
LogMetrics(Dictionary<string, T>, int, DateTime?)
Logs multiple metrics at once for a specific step.
void LogMetrics(Dictionary<string, T> metrics, int step = 0, DateTime? timestamp = null)
Parameters
metricsDictionary<string, T>Dictionary of metric names and values.
stepintThe training step/iteration number.
timestampDateTime?Optional timestamp for the metrics.
LogModel<TInput, TOutput, TMetadata>(IModel<TInput, TOutput, TMetadata>, string?)
Logs a trained model as an artifact.
void LogModel<TInput, TOutput, TMetadata>(IModel<TInput, TOutput, TMetadata> model, string? artifactPath = null) where TInput : class where TOutput : class where TMetadata : class
Parameters
modelIModel<TInput, TOutput, TMetadata>The model to log.
artifactPathstringOptional path within the artifact store.
Type Parameters
TInputTOutputTMetadata
LogParameter(string, object)
Logs a single parameter value for this run.
void LogParameter(string key, object value)
Parameters
Remarks
For Beginners: Parameters are the settings you chose for this training run, like learning rate, batch size, or number of layers. These are typically set at the start of training and don't change during the run.
LogParameters(Dictionary<string, object>)
Logs multiple parameters at once.
void LogParameters(Dictionary<string, object> parameters)
Parameters
parametersDictionary<string, object>Dictionary of parameter names and values.