RandomApply¶
- class torchvision.transforms.RandomApply(transforms, p=0.5)[source]¶
以给定的概率随机应用一系列变换。
注意
为了编写变换脚本,请使用
torch.nn.ModuleList
作为输入,而不是如下所示的变换列表/元组>>> transforms = transforms.RandomApply(torch.nn.ModuleList([ >>> transforms.ColorJitter(), >>> ]), p=0.3) >>> scripted_transforms = torch.jit.script(transforms)
请确保仅使用可编写脚本的变换,即适用于
torch.Tensor
的变换,不需要 lambda 函数或PIL.Image
。- 参数:
transforms (sequence 或 torch.nn.Module) – 变换列表
p (float) – 概率
使用
RandomApply
的示例