Class LabelMixingEventArgs<T>
- Namespace
- AiDotNet.Augmentation
- Assembly
- AiDotNet.dll
Event arguments for label mixing operations in augmentations like Mixup and CutMix.
public class LabelMixingEventArgs<T> : EventArgs
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
LabelMixingEventArgs<T>
- Inherited Members
Remarks
When augmentations like Mixup or CutMix are applied, they blend data from two samples together. The labels must also be blended proportionally. This event allows the training loop to handle the soft label generation appropriately.
For Beginners: In normal classification, an image is 100% one class (like "cat"). With Mixup/CutMix, we blend two images together, so the label becomes something like "70% cat, 30% dog". This helps the model learn smoother decision boundaries.
Constructors
LabelMixingEventArgs(Vector<T>, Vector<T>, T, int, int, MixingStrategy)
Creates a new label mixing event.
public LabelMixingEventArgs(Vector<T> originalLabels1, Vector<T> originalLabels2, T mixingLambda, int sampleIndex1, int sampleIndex2, MixingStrategy strategy)
Parameters
originalLabels1Vector<T>The labels for the first sample.
originalLabels2Vector<T>The labels for the second sample.
mixingLambdaTThe mixing coefficient.
sampleIndex1intThe index of the first sample.
sampleIndex2intThe index of the second sample.
strategyMixingStrategyThe mixing strategy used.
Properties
Metadata
Gets additional metadata about the mixing operation.
public IDictionary<string, object> Metadata { get; }
Property Value
Remarks
For CutMix, this may contain the bounding box coordinates of the cut region.
MixedLabels
Gets or sets the resulting mixed soft labels.
public Vector<T>? MixedLabels { get; set; }
Property Value
- Vector<T>
Remarks
The training loop should set this to: lambda * OriginalLabels1 + (1 - lambda) * OriginalLabels2
MixingLambda
Gets the mixing coefficient (lambda).
public T MixingLambda { get; }
Property Value
- T
Remarks
For Mixup: lambda determines the blend ratio. For CutMix: lambda represents the area ratio of the original image kept.
OriginalLabels1
Gets the original hard labels for the first sample.
public Vector<T> OriginalLabels1 { get; }
Property Value
- Vector<T>
OriginalLabels2
Gets the original hard labels for the second (mixed) sample.
public Vector<T> OriginalLabels2 { get; }
Property Value
- Vector<T>
SampleIndex1
Gets the index of the first sample in the batch.
public int SampleIndex1 { get; }
Property Value
SampleIndex2
Gets the index of the second sample in the batch.
public int SampleIndex2 { get; }
Property Value
Strategy
Gets the mixing strategy used.
public MixingStrategy Strategy { get; }