pycsamt.ai.training.augment#
Data augmentation for EM training datasets.
Augmenters are callable objects that accept (X, y) numpy pairs
and return modified copies. They are designed to be composed with
Compose and used inside a training loop or as a preprocessing
step on EMDataset.
Available augmenters#
AugmentNoiseAdditive log-Gaussian noise on feature amplitudes.
AugmentStaticShiftRandom static shift — multiply all log-amplitude features by a site-specific constant drawn from a log-uniform distribution.
AugmentFreqDropRandomly zero-out a fraction of frequency channels.
AugmentMixupConvex combination of two training samples (Zhang et al. 2018).
ComposeSequential chain of augmenters.
RandomApplyApply an augmenter with probability p.
Classes
|
Randomly zero-out a fraction of frequency channels. |
|
Mixup augmentation (Zhang et al. 2018). |
|
Add multiplicative log-Gaussian noise to feature amplitudes. |
|
Apply a random static shift to amplitude features. |
|
Sequentially apply a list of augmenters. |
|
Apply an augmenter with probability p. |
- class pycsamt.ai.training.augment.AugmentNoise(sigma=0.05, phase_sigma=None, clip=3.0)[source]#
Bases:
_BaseAugmenterAdd multiplicative log-Gaussian noise to feature amplitudes.
For each sample a noise vector
\[\boldsymbol{\varepsilon} \sim \mathcal{N}(\mathbf{0},\, \sigma^2 \mathbf{I})\]is added to the feature vector. If
phase_sigmais given a separate (typically smaller) noise level is used on phase features (assumed to occupy the second half of the feature vector wheninclude_phase=True).
- class pycsamt.ai.training.augment.AugmentStaticShift(shift_range=(0.3, 3.0), n_amp_features=None, per_sample=True)[source]#
Bases:
_BaseAugmenterApply a random static shift to amplitude features.
Static shift is a common MT artefact: all apparent-resistivity values at one site are scaled by a constant factor due to local near-surface heterogeneity. This augmenter simulates the effect by multiplying the first
n_amp_featuresfeature columns by a site-specific log-uniform random factor.- Parameters:
shift_range ((lo, hi), default (0.3, 3.0)) – Range of the multiplicative factor in linear scale.
n_amp_features (int or None) – Number of amplitude columns at the start of the feature vector.
None→ shift all features (use when features are log₁₀ amplitude only, without phase).per_sample (bool) – If
Truedraw an independent shift for each sample; otherwise draw one shift per batch.
- class pycsamt.ai.training.augment.AugmentFreqDrop(drop_rate=0.1, contiguous=False, fill_value=0.0)[source]#
Bases:
_BaseAugmenterRandomly zero-out a fraction of frequency channels.
Simulates missing data at individual frequencies (bad data periods, cultural noise bursts, dead-band contamination).
- class pycsamt.ai.training.augment.AugmentMixup(alpha=0.2)[source]#
Bases:
_BaseAugmenterMixup augmentation (Zhang et al. 2018).
Randomly pairs samples within the batch and creates convex combinations:
\[\tilde{\mathbf{x}} = \lambda \mathbf{x}_i + (1-\lambda) \mathbf{x}_j, \quad \tilde{\mathbf{y}} = \lambda \mathbf{y}_i + (1-\lambda) \mathbf{y}_j\]where \(\lambda \sim \mathrm{Beta}(\alpha, \alpha)\).
- Parameters:
alpha (float, default 0.2) – Beta distribution shape parameter. Small values (≈0.1) produce near-original samples;
alpha=1.0is uniform mixing.
- class pycsamt.ai.training.augment.Compose(augmenters, seed=None)[source]#
Bases:
objectSequentially apply a list of augmenters.
- Parameters:
Examples
>>> aug = Compose([ ... AugmentStaticShift(shift_range=(0.5, 2.0)), ... AugmentNoise(sigma=0.03), ... AugmentFreqDrop(drop_rate=0.05), ... ]) >>> X_aug, y_aug = aug(X_train, y_train)