AugmentationContext<T>

Models & Types · AiDotNet.Augmentation

Provides runtime context for augmentation operations including random state, training mode, and spatial targets.

Constructors

Constructor Summary
AugmentationContext(Random random, bool isTraining) Creates a new augmentation context with a provided random instance.
AugmentationContext(bool isTraining, int? seed) Creates a new augmentation context with a provided random instance.

Properties

Property Summary
IDictionary<string, object> Metadata { get; } Gets additional metadata for the current augmentation.
Random Random { get; } Gets the random number generator for this context.
bool IsTraining { get; } Gets whether the context is in training mode.
int BatchIndex { get; set; } Gets the batch index (if applicable).
int SampleIndex { get; set; } Gets the sample index within the batch (if applicable).

Methods

Method Summary
AugmentationContext<T> CreateChildContext(int sampleIndex) Creates a child context with the same random state but different indices.
bool GetRandomBool() Gets a random boolean with 50% probability.
bool ShouldApply(double probability) Determines whether an augmentation with the given probability should be applied.
double GetRandomDouble(double min, double max) Gets a random value within the specified range.
double SampleBeta(double alpha, double beta) Samples from a Beta distribution (used by Mixup/CutMix).
double SampleGaussian(double mean, double stdDev) Samples from a Gaussian (normal) distribution.
int GetRandomInt(int min, int max) Gets a random integer within the specified range.