- class torchvision.transforms.RandomApply(transforms, p=0.5)¶
Apply randomly a list of transformations with a given probability.
In order to script the transformation, please use
torch.nn.ModuleListas 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
RandomApply:Illustration of transforms
Defines the computation performed at every call.
Should be overridden by all subclasses.
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.