Skip to content
class

AutoAugment

extendsPhotometricTransform[_AutoAugmentParams]
AutoAugment(policy: str = 'imagenet', num_magnitude_bins: int = 10, interpolation: str | Interpolation = Interpolation.BILINEAR, fill: float = 0.0, p: float = 1.0)

AutoAugment (Cubuk et al., 2019 — arXiv:1805.09501).

Each call samples one of 25 fixed sub-policies uniformly; each sub-policy is two (op, probability, magnitude_idx) triples applied sequentially with their own probability gates. Three policy tables are shipped, verbatim from the paper:

  • "imagenet" — Table 2 (default). General-purpose vision classification.
  • "cifar10" — Table 6. Small-image classification.
  • "svhn" — Table 7. Digits / OCR-style data.

Parameters

policystr= "imagenet"
Which policy table to sample sub-policies from. Must be one of "imagenet", "cifar10", "svhn".
num_magnitude_binsint= 10
Magnitude bin count. The paper / reference framework uses 10 for AutoAugment (vs. 31 for RandAugment / TrivialAugmentWide); the policy tables index into this size.
interpolationstr or Interpolation= "bilinear"
No description.
fillfloat= 0.0
No description.
pfloat= 1.0
No description.

Notes

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

Examples

>>> import lucid
>>> from lucid.utils.transforms import AutoAugment
>>> tf = AutoAugment(policy="imagenet")
>>> x = lucid.rand(3, 224, 224)
>>> y = tf(x)
>>> tuple(y.shape)
(3, 224, 224)

Used by 2

Constructors

1
dunder

__init__

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

Instance methods

1
fn

make_params

→_AutoAugmentParams
make_params(img: Tensor)

Sample per-call random parameters for AutoAugment.

Parameters

Image tensor; not inspected, carried through for dispatch.

Returns

_AutoAugmentParams

Carries ops — the resolved sequence of (op_name, signed_magnitude) pairs after sampling one sub-policy uniformly from the active policy table and gating each sub-op by its per-policy probability. Ops in NO_MAGNITUDE_OPS are emitted with magnitude 0.0; ops in SIGNED_OPS get a random sign on the table-lookup magnitude.

Dunder methods

1