Table of Contents

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

T

The 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

isTraining bool

Whether the context is in training mode.

seed int?

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

random Random

The random number generator to use.

isTraining bool

Whether the context is in training mode.

Properties

BatchIndex

Gets the batch index (if applicable).

public int BatchIndex { get; set; }

Property Value

int

IsTraining

Gets whether the context is in training mode.

public bool IsTraining { get; }

Property Value

bool

Metadata

Gets additional metadata for the current augmentation.

public IDictionary<string, object> Metadata { get; }

Property Value

IDictionary<string, object>

Random

Gets the random number generator for this context.

public Random Random { get; }

Property Value

Random

SampleIndex

Gets the sample index within the batch (if applicable).

public int SampleIndex { get; set; }

Property Value

int

Methods

CreateChildContext(int)

Creates a child context with the same random state but different indices.

public AugmentationContext<T> CreateChildContext(int sampleIndex)

Parameters

sampleIndex int

The 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

min double

The minimum value (inclusive).

max double

The maximum value (exclusive).

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

min int

The minimum value (inclusive).

max int

The maximum value (exclusive).

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

alpha double

The alpha parameter.

beta double

The beta parameter.

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

mean double

The mean of the distribution.

stdDev double

The standard deviation of the distribution.

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

probability double

The probability (0.0 to 1.0).

Returns

bool

True if the augmentation should be applied.