Class AugmentationContext<T>
- Namespace
- AiDotNet.Augmentation
- Assembly
- AiDotNet.dll
Provides runtime context for augmentation operations including random state, training mode, and spatial targets.
public class AugmentationContext<T>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationContext<T>
- Inherited Members
Constructors
AugmentationContext(bool, int?)
Creates a new augmentation context.
public AugmentationContext(bool isTraining = true, int? seed = null)
Parameters
isTrainingboolWhether the context is in training mode.
seedint?Optional seed for reproducibility.
AugmentationContext(Random, bool)
Creates a new augmentation context with a provided random instance.
public AugmentationContext(Random random, bool isTraining = true)
Parameters
randomRandomThe random number generator to use.
isTrainingboolWhether the context is in training mode.
Properties
BatchIndex
Gets the batch index (if applicable).
public int BatchIndex { get; set; }
Property Value
IsTraining
Gets whether the context is in training mode.
public bool IsTraining { get; }
Property Value
Metadata
Gets additional metadata for the current augmentation.
public IDictionary<string, object> Metadata { get; }
Property Value
Random
Gets the random number generator for this context.
public Random Random { get; }
Property Value
SampleIndex
Gets the sample index within the batch (if applicable).
public int SampleIndex { get; set; }
Property Value
Methods
CreateChildContext(int)
Creates a child context with the same random state but different indices.
public AugmentationContext<T> CreateChildContext(int sampleIndex)
Parameters
sampleIndexintThe sample index for the child context.
Returns
- AugmentationContext<T>
A new child context.
GetRandomBool()
Gets a random boolean with 50% probability.
public bool GetRandomBool()
Returns
- bool
A random boolean.
GetRandomDouble(double, double)
Gets a random value within the specified range.
public double GetRandomDouble(double min, double max)
Parameters
Returns
- double
A random value in the range [min, max).
GetRandomInt(int, int)
Gets a random integer within the specified range.
public int GetRandomInt(int min, int max)
Parameters
Returns
- int
A random integer in the range [min, max).
SampleBeta(double, double)
Samples from a Beta distribution (used by Mixup/CutMix).
public double SampleBeta(double alpha, double beta)
Parameters
Returns
- double
A sample from Beta(alpha, beta).
SampleGaussian(double, double)
Samples from a Gaussian (normal) distribution.
public double SampleGaussian(double mean, double stdDev)
Parameters
Returns
- double
A sample from N(mean, stdDev^2).
ShouldApply(double)
Determines whether an augmentation with the given probability should be applied.
public bool ShouldApply(double probability)
Parameters
probabilitydoubleThe probability (0.0 to 1.0).
Returns
- bool
True if the augmentation should be applied.