Class AugmentationBase<T, TData>
- Namespace
- AiDotNet.Augmentation
- Assembly
- AiDotNet.dll
Abstract base class for all augmentations providing common functionality.
public abstract class AugmentationBase<T, TData> : IAugmentation<T, TData>
Type Parameters
TThe numeric type for calculations.
TDataThe data type being augmented.
- Inheritance
-
AugmentationBase<T, TData>
- Implements
-
IAugmentation<T, TData>
- Derived
- Inherited Members
Remarks
AugmentationBase provides: - Probability-based application control - Training/inference mode awareness - Parameter serialization - Event hooks for monitoring
For Beginners: This is the foundation that all augmentations build upon. It handles common tasks like deciding whether to apply the augmentation based on probability, tracking parameters, and ensuring augmentations behave correctly during training vs. inference.
Constructors
AugmentationBase(double)
Initializes a new instance of the augmentation.
protected AugmentationBase(double probability = 1)
Parameters
probabilitydoubleThe probability of applying this augmentation (0.0 to 1.0).
Fields
NumOps
Numeric operations for type T.
protected static readonly INumericOperations<T> NumOps
Field Value
- INumericOperations<T>
Properties
IsEnabled
Gets or sets whether this augmentation is currently enabled.
public bool IsEnabled { get; set; }
Property Value
IsTrainingOnly
Gets whether this augmentation should only be applied during training.
public virtual bool IsTrainingOnly { get; }
Property Value
Name
Gets the name of this augmentation.
public virtual string Name { get; }
Property Value
Probability
Gets the probability of this augmentation being applied.
public double Probability { get; protected set; }
Property Value
Methods
Apply(TData, AugmentationContext<T>?)
Applies the augmentation to the input data.
public TData Apply(TData data, AugmentationContext<T>? context = null)
Parameters
dataTDataThe input data.
contextAugmentationContext<T>The augmentation context.
Returns
- TData
The augmented data (or original if not applied).
ApplyAugmentation(TData, AugmentationContext<T>)
Implement this method to perform the actual augmentation.
protected abstract TData ApplyAugmentation(TData data, AugmentationContext<T> context)
Parameters
dataTDataThe input data.
contextAugmentationContext<T>The augmentation context.
Returns
- TData
The augmented data.
GetParameters()
Gets the parameters of this augmentation.
public virtual IDictionary<string, object> GetParameters()
Returns
- IDictionary<string, object>
A dictionary of parameter names to values.
RaiseAugmentationApplied(AugmentationContext<T>, bool)
Raises the augmentation applied event.
protected void RaiseAugmentationApplied(AugmentationContext<T> context, bool wasApplied)
Parameters
contextAugmentationContext<T>wasAppliedbool
Events
OnAugmentationApplied
Event raised when this augmentation is applied.
public event EventHandler<AugmentationAppliedEventArgs<T>>? OnAugmentationApplied