RandomApply

class torchaug.transforms.RandomApply(transforms, p=0.5)[source]

Apply randomly a list of transformations with a given probability.

Note

In order to script the transformation, please use torch.nn.ModuleList as input instead of list/tuple of transforms as shown below:

>>> transforms = transforms.RandomApply(torch.nn.ModuleList([
>>>     transforms.ColorJitter(),
>>> ]), p=0.3)
>>> scripted_transforms = torch.jit.script(transforms)

Make sure to use only scriptable transformations, i.e. that work with torch.Tensor, does not require lambda functions or PIL.Image.

Parameters:
extra_repr()[source]

Set the extra representation of the transform.

Return type:

str

forward(*inputs)[source]

Performs forward pass of the transform.

Parameters:

inputs (Any) – Inputs to the transform.

Return type:

Any

Returns:

Transformed inputs.