Operations
Some commands, such as train or fork, support passing a series of optional operations via the --operations option.
Operations provide a flexible way to design data augmentation pipelines, by composing a sequence of primitive data operations to be applied to the data, specified as case-insensitive, python-like functions calls.
For instance, consider a configuration file that specifies the following data augmentation operations:
- yaml
- toml
cmd: train
input: data.json
operations:
- sub(value=mean, axis=feature)
- div(value=std, axis=feature)
- mulrand(range=(-0.1, 0.1), log=true)
- mul(value=std, axis=feature)
- add(value=mean, axis=feature)
cmd = "train"
input = "data.json"
operations = [
"sub(value=mean, axis=feature)",
"div(value=std, axis=feature)",
"mulrand(range=(-0.1, 0.1), log=true)",
"mul(value=std, axis=feature)",
"add(value=mean, axis=feature)",
]
Note that text-like values such as mean or std are not in quotes.
In this example, the operations are applied in the order below. The statistics mean and std are always computed feature-wise on the original, unaugmented data.
sub: Subtract the mean along the feature axis from the data.div: Divide the result by the standard deviation along the feature axis. The data is now standardized.mulrand: Multiply the result globally by random factor2 ** u, whereuis drawn uniformly from the range(-0.1, 0.1). The factor therefore lies between2 ** -0.1and2 ** 0.1.mul: Multiply the result by the standard deviation, undoing step 2.add: Add the mean to the result, undoing step 1. The data is back on its original scale.
For any augmentation pipeline, make ensure your data always remains in a realistic range. Poorly designed data augmentation pipelines might result in worse training outcomes.