快捷方式

RandAugment

class torchvision.transforms.RandAugment(num_ops: int = 2, magnitude: int = 9, num_magnitude_bins: int = 31, interpolation: InterpolationMode = InterpolationMode.NEAREST, fill: Optional[List[float]] = None)[source]

RandAugment 資料擴充方法基於 “RandAugment: Practical automated data augmentation with a reduced search space”。如果影像是 torch Tensor,則應為 torch.uint8 類型,並且預期具有 […, 1 或 3, H, W] 形狀,其中 … 表示任意數量的領先維度。如果 img 是 PIL 影像,則預期為 “L” 或 “RGB” 模式。

參數:
  • num_ops (int) – 依序套用的擴充轉換次數。

  • magnitude (int) – 所有轉換的強度。

  • num_magnitude_bins (int) – 不同強度值的數量。

  • interpolation (InterpolationMode) – 期望的插值枚舉,由 torchvision.transforms.InterpolationMode 定義。預設值為 InterpolationMode.NEAREST。如果輸入是 Tensor,則僅支援 InterpolationMode.NEARESTInterpolationMode.BILINEAR

  • fill (sequencenumber, optional) – 轉換後圖像外部區域的像素填充值。如果給定一個數字,則該值將分別用於所有通道。

使用 RandAugment 的範例

轉換的說明

轉換的說明
forward(img: Tensor) Tensor[source]

img (PIL Image 或 Tensor): 要轉換的圖像。

返回值:

轉換後的圖像。

返回類型:

PIL Image 或 Tensor

文件

存取 PyTorch 的全面開發者文件

檢視文件

教學課程

取得適合初學者和進階開發人員的深入教學課程

檢視教學課程

資源

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

檢視資源