RandAugment
PhotometricTransform[_RandAugmentParams]RandAugment(num_ops: int = 2, magnitude: int = 9, num_magnitude_bins: int = 31, interpolation: str | Interpolation = Interpolation.BILINEAR, fill: float = 0.0, p: float = 1.0)RandAugment (Cubuk et al., 2020 — arXiv:1909.13719).
Each call samples num_ops ops uniformly with replacement from
the 14-op vocabulary and applies them sequentially, all sharing
the same magnitude (signed per-op for symmetric ops).
Reduces AutoAugment's two-level search space (policy + magnitude)
to two scalar hyper-parameters that can be tuned with a simple
grid sweep.
Parameters
num_opsint= 2magnitudeint= 90 <= magnitude < num_magnitude_bins. Reference-framework
recipes sweep this from 5 (small models) to 15 (large models).num_magnitude_binsint= 31TrivialAugmentWide.fillfloat= 0.0pfloat= 1.0Notes
Photometric (image-only) by Lucid convention — see the module
docstring. The op draws are with replacement so a call may stack
the same op twice (e.g. Rotate followed by Rotate); this is
the reference-framework behaviour.
Examples
>>> import lucid
>>> from lucid.utils.transforms import RandAugment
>>> tf = RandAugment(num_ops=2, magnitude=9)
>>> x = lucid.rand(3, 224, 224)
>>> y = tf(x)
>>> tuple(y.shape)
(3, 224, 224)Used by 2
Constructors
1Instance methods
1Sample per-call random parameters for RandAugment.
Parameters
imgTensorReturns
_RandAugmentParamsCarries ops — a length-num_ops tuple of
(op_name, signed_magnitude) pairs. Op names are drawn
uniformly with replacement from the 14-op vocabulary; the
magnitude shared across all ops is fixed at the
self.magnitude lookup index, with a random sign for
ops in SIGNED_OPS.