Skip to content
class

TrivialAugmentWide

extendsPhotometricTransform[_SingleOpParams]
TrivialAugmentWide(num_magnitude_bins: int = 31, interpolation: str | Interpolation = Interpolation.BILINEAR, fill: float = 0.0, p: float = 1.0)

Trivial Augment Wide (Müller & Hutter, 2021 — arXiv:2103.10158).

Each call draws one op uniformly from the 14-op vocabulary and one magnitude uniformly from [0, num_magnitude_bins). Despite its simplicity it matches the accuracy of much more elaborate policies (AutoAugment, RandAugment) on ImageNet — making it the default "set-and-forget" augmentation in modern recipes.

Parameters

num_magnitude_binsint= 31
Magnitude bin count. The wide variant uses 31; the original TrivialAugment uses 10. Larger values give a finer magnitude grid.
interpolationstr or Interpolation= "bilinear"
Resample mode for the geometric ops (Shear / Translate / Rotate).
fillfloat= 0.0
Border fill value for the geometric warps.
pfloat= 1.0
Probability of applying the policy at all. TrivialAugment is designed to fire every call (Identity is one of the 14 ops, so ~7% of calls are no-ops by virtue of the op draw); the p knob is provided for compositional consistency, not because p < 1 is recommended.

Notes

Photometric (image-only) by Lucid convention — see the module docstring.

Examples

>>> import lucid
>>> from lucid.utils.transforms import TrivialAugmentWide
>>> tf = TrivialAugmentWide()
>>> x = lucid.rand(3, 224, 224)
>>> y = tf(x)
>>> tuple(y.shape)
(3, 224, 224)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(num_magnitude_bins: int = 31, interpolation: str | Interpolation = Interpolation.BILINEAR, fill: float = 0.0, p: float = 1.0)

Instance methods

1
fn

make_params

→_SingleOpParams
make_params(img: Tensor)

Sample per-call random parameters for TrivialAugmentWide.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

_SingleOpParams

Carries the sampled op_name (uniform over the 14-op vocabulary) and magnitude — either 0.0 for ops in NO_MAGNITUDE_OPS, or magnitudes[mag_idx] (with a random sign for ops in SIGNED_OPS) where mag_idx is uniform over [0, num_magnitude_bins).

Dunder methods

1