快捷方式

RandomApply

class torchvision.transforms.v2.RandomApply(transforms: Union[Sequence[Callable], ModuleList], p: float = 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 (sequencetorch.nn.Module) – 轉換列表

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

使用 RandomApply 的範例

轉換的圖示

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

傳回模組的額外表示。

要印出客製化的額外資訊,您應該在自己的模組中重新實作此方法。單行和多行字串都是可接受的。

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

不要覆寫這個!請改用 transform()

文件

存取 PyTorch 的完整開發人員文件

檢視文件

教學

取得針對初學者和進階開發人員的深入教學

檢視教學

資源

尋找開發資源並取得您問題的解答

檢視資源