SelfSupervisedLearningSession<T>
Models & Types · AiDotNet.SelfSupervisedLearning
Manages a self-supervised learning training session.
For Beginners
An SSL session manages the entire training lifecycle: initialization, training loop, evaluation, and checkpointing. It provides callbacks for monitoring progress and supports resuming from checkpoints.
Constructors
| Constructor | Summary |
|---|---|
SelfSupervisedLearningSession(ISelfSupervisedLearningMethod<T> method, SelfSupervisedLearningConfig<T> config) |
Initializes a new SSL training session. |
Properties
| Property | Summary |
|---|---|
ISelfSupervisedLearningMethod<T> Method { get; } |
Gets the SSL method being used. |
bool IsDistributed { get; } |
Gets whether this session is using distributed training. |
bool IsTraining { get; } |
Gets whether training is in progress. |
int CurrentEpoch { get; } |
Gets the current epoch number. |
int GlobalStep { get; } |
Gets the global step counter. |
int Rank { get; } |
Gets the rank of this worker in distributed training. |
int WorldSize { get; } |
Gets the world size (number of workers) for distributed training. |
Methods
| Method | Summary |
|---|---|
SelfSupervisedLearningMetricReport<T> Evaluate(Tensor<T> data) |
Runs evaluation on the current encoder. |
SelfSupervisedLearningResult<T> Train(Func<IEnumerable<Tensor<T>>> dataLoader, Tensor<T> validationData, int[] validationLabels) |
Trains the SSL method for the specified number of epochs. |
SelfSupervisedLearningSession<T> FromCheckpoint(string checkpointPath, INeuralNetwork<T> encoder, Func<INeuralNetwork<T>, ISelfSupervisedLearningMethod<T>> methodFactory) |
Creates a session from a pretrained checkpoint. |
SelfSupervisedLearningTrainingHistory<T> GetHistory() |
Gets the current training history. |
int GetEffectiveBatchSize() |
Gets the effective batch size considering distributed training. |
void CacheTrainingFeaturesForKNN(IEnumerable<Tensor<T>> trainingData, int[] trainingLabels) |
Caches training data for k-NN evaluation. |
void Reset() |
Resets the session for a new training run. |
void SaveCheckpoint(string checkpointPath) |
Saves a checkpoint to disk. |
void Stop() |
Stops training gracefully. |
void SynchronizeParameters() |
Synchronizes model parameters across all distributed workers. |