Class ExperimentRun<T>
Represents a single training run within an experiment.
public class ExperimentRun<T> : IExperimentRun<T>
Type Parameters
TThe numeric data type used for calculations.
- Inheritance
-
ExperimentRun<T>
- Implements
- Inherited Members
Remarks
For Beginners: A run captures all the details of one training session, including parameters, metrics, and artifacts.
This class is thread-safe and can be safely accessed from multiple threads concurrently.
Constructors
ExperimentRun(string, string?, Dictionary<string, string>?)
Initializes a new instance of the ExperimentRun class.
public ExperimentRun(string experimentId, string? runName = null, Dictionary<string, string>? tags = null)
Parameters
experimentIdstringThe experiment ID this run belongs to.
runNamestringOptional name for the run.
tagsDictionary<string, string>Optional tags.
Properties
EndTime
Gets the timestamp when the run ended.
[JsonProperty]
public DateTime? EndTime { get; }
Property Value
ExperimentId
Gets the experiment ID this run belongs to.
[JsonProperty]
public string ExperimentId { get; }
Property Value
RunId
Gets the unique identifier for this run.
[JsonProperty]
public string RunId { get; }
Property Value
RunName
Gets or sets the name of this run.
public string? RunName { get; set; }
Property Value
StartTime
Gets the timestamp when the run was started.
[JsonProperty]
public DateTime StartTime { get; }
Property Value
Status
Gets the current status of the run.
[JsonProperty]
public string Status { get; }
Property Value
Tags
Gets the tags associated with this run in a thread-safe manner.
[JsonProperty]
public ConcurrentDictionary<string, string> Tags { get; }
Property Value
Methods
AddNote(string)
Adds a note or comment to the run.
public void AddNote(string note)
Parameters
notestring
Complete()
Marks the run as completed successfully.
public void Complete()
Fail(string?)
Marks the run as failed with an optional error message.
public void Fail(string? errorMessage = null)
Parameters
errorMessagestring
GetArtifacts()
Gets all artifacts logged for this run.
public List<string> GetArtifacts()
Returns
GetDuration()
Gets the duration of the run.
public TimeSpan? GetDuration()
Returns
GetErrorMessage()
Gets the error message if the run failed.
public string? GetErrorMessage()
Returns
GetLatestMetric(string)
Gets the latest value for a specific metric.
public T? GetLatestMetric(string metricName)
Parameters
metricNamestring
Returns
- T
GetMetrics()
Gets all metrics logged for this run.
public Dictionary<string, List<(int Step, T Value, DateTime Timestamp)>> GetMetrics()
Returns
GetNotes()
Gets all notes added to this run.
public List<(DateTime Timestamp, string Note)> GetNotes()
Returns
GetParameters()
Gets all parameters logged for this run.
public Dictionary<string, object> GetParameters()
Returns
LogArtifact(string, string?)
Logs an artifact (file) associated with this run.
public void LogArtifact(string localPath, string? artifactPath = null)
Parameters
LogArtifacts(string, string?)
Logs a directory of artifacts.
public void LogArtifacts(string localDir, string? artifactPath = null)
Parameters
LogMetric(string, T, int, DateTime?)
Logs a metric value at a specific step/iteration.
public void LogMetric(string key, T value, int step = 0, DateTime? timestamp = null)
Parameters
LogMetrics(Dictionary<string, T>, int, DateTime?)
Logs multiple metrics at once for a specific step.
public void LogMetrics(Dictionary<string, T> metrics, int step = 0, DateTime? timestamp = null)
Parameters
metricsDictionary<string, T>stepinttimestampDateTime?
LogModel<TInput, TOutput, TMetadata>(IModel<TInput, TOutput, TMetadata>, string?)
Logs a trained model as an artifact.
public void LogModel<TInput, TOutput, TMetadata>(IModel<TInput, TOutput, TMetadata> model, string? artifactPath = null) where TInput : class where TOutput : class where TMetadata : class
Parameters
Type Parameters
TInputTOutputTMetadata
LogParameter(string, object)
Logs a single parameter value for this run.
public void LogParameter(string key, object value)
Parameters
LogParameters(Dictionary<string, object>)
Logs multiple parameters at once.
public void LogParameters(Dictionary<string, object> parameters)
Parameters
parametersDictionary<string, object>