RandomApply¶
- class torchvision.transforms.v2.RandomApply(transforms: Union[Sequence[Callable], ModuleList], p: float = 0.5)[原始碼]¶
以給定的機率隨機應用一系列變換。
注意
為了指令碼化轉換,請使用
torch.nn.ModuleList作為輸入,而不是像下面這樣使用 list/tuple 的轉換。>>> 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的示例