niacin.augment package¶
Submodules¶
niacin.augment.randaugment module¶
Implementation of RandAugment algorithm
-
class
niacin.augment.randaugment.
RandAugment
(transforms: List[Callable], m: int = 10, n: int = 1, shuffle: bool = True, seed: int = None)[source]¶ Bases:
object
Implements RandAugment algorithm (randaugment) as an iterator. RandAugment selects
n
functions at random from a sequence, and initializes them with magnitudem
.To use it, initialize this class with a list of transformation functions. Every time it is iterated over (e.g. in a for loop) it yields a random subset of those transformation functions.
The original paper claims that m is on a scale from 0-10, but its listed experiments regularly use magnitudes in the 20s and 30s. We take this to mean that “10” was a typo, and the scale was meant to extend to 100.
The defaults for m and n have been set to 1 and 10, respectively, for safety. Depending on your model size and task, you may achieve more accurate results with n ∈ {2, 3} and an m in the range [10, 20). By default, the transforms in a single sample will be returned in random order. If your transforms must occur in a logical sequence (e.g. swapping synonyms before removing random characters), set shuffle to False.
Parameters: - transforms – sequence of transformation functions
- m – magnitude of transformation, on a scale of 0-100
- n – number of transforms to select
- shuffle – return transforms in random order
- seed – seed to use for the random number generator
-
m
¶ Magnitude of transformation - should be a number between 0 and 100
-
n
¶ Size of sample - should be less than total available transforms