ITrainingMonitor<T>

Interfaces · AiDotNet.Interfaces

Defines the contract for training monitoring systems that track and visualize model training progress.

Known implementations: TrainingMonitorBase<T>

How It Works

A training monitor provides real-time visibility into the training process, tracking metrics, system resources, and training state to help identify issues and optimize performance.

For Beginners: Think of a training monitor as a dashboard for your model training. Just like a car dashboard shows speed, fuel, and engine temperature, a training monitor shows:

  • Training metrics (loss, accuracy)
  • System resources (CPU, GPU, memory usage)
  • Training speed (iterations per second)
  • Progress and estimated time remaining

Why training monitoring matters:

  • Catch problems early (model not learning, overfitting, resource issues)
  • Understand training dynamics and patterns
  • Optimize resource usage
  • Track progress on long-running training jobs
  • Enable remote monitoring of training

Methods

Method Summary
Dictionary<string, T> GetCurrentMetrics(string sessionId) Gets the current metrics for a session.
List<ValueTuple<int, T, DateTime>> GetMetricHistory(string sessionId, string metricName) Gets the history of a specific metric.
List<string> CheckForIssues(string sessionId) Checks for potential training issues and returns warnings.
ResourceUsageStats GetResourceUsage(string sessionId) Gets the current resource usage.
TrainingSpeedStats GetSpeedStats(string sessionId) Gets statistics about training speed.
string StartSession(string sessionName, Dictionary<string, object> metadata) Starts monitoring a training session.
void CreateVisualization(string sessionId, List<string> metricNames, string outputPath) Creates a visualization of training metrics.
void EndSession(string sessionId) Ends the current monitoring session.
void ExportData(string sessionId, string filePath, string format) Exports monitoring data to a file.
void LogMessage(string sessionId, LogLevel level, string message) Logs a text message or event during training.
void LogMetric(string sessionId, string metricName, T value, int step, DateTime? timestamp) Records a metric value for the current training step.
void LogMetrics(string sessionId, Dictionary<string, T> metrics, int step) Records multiple metrics at once.
void LogResourceUsage(string sessionId, double cpuUsage, double memoryUsage, double? gpuUsage, double? gpuMemory) Records system resource usage.
void OnEpochEnd(string sessionId, int epochNumber, Dictionary<string, T> metrics, TimeSpan duration) Records the end of a training epoch with summary metrics.
void OnEpochStart(string sessionId, int epochNumber) Records the start of a new training epoch.
void UpdateProgress(string sessionId, int currentStep, int totalSteps, int currentEpoch, int totalEpochs) Updates the training progress information.