快捷方式

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 (sequencetorch.nn.Module) – 轉換列表

  • p (float) – 應用轉換列表的機率

使用 RandomApply 的示例

轉換圖示

轉換圖示
extra_repr() str[原始碼]

返回模組的額外表示。

要列印自定義額外資訊,您應該在自己的模組中重新實現此方法。單行和多行字串均可接受。

forward(*inputs: Any) Any[原始碼]

不要覆蓋此方法!請使用 transform() 代替。

文件

訪問全面的 PyTorch 開發者文件

檢視文件

教程

為初學者和高階開發者提供深入的教程

檢視教程

資源

查詢開發資源並讓您的問題得到解答

檢視資源