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)[源码]¶
RandAugment 数据增强方法,基于 “RandAugment: Practical automated data augmentation with a reduced search space”。如果图像是 torch Tensor,则应为 torch.uint8 类型,并且期望形状为 […, 1 or 3, H, W],其中 … 表示任意数量的前导维度。如果 img 是 PIL Image,则期望模式为 “L” 或 “RGB”。
- 参数:
num_ops (int) – 顺序应用的增强变换次数。
magnitude (int) – 所有变换的强度。
num_magnitude_bins (int) – 不同的强度值数量。
interpolation (InterpolationMode) – 由
torchvision.transforms.InterpolationMode
定义的所需插值枚举。默认值为InterpolationMode.NEAREST
。如果输入是 Tensor,仅支持InterpolationMode.NEAREST
和InterpolationMode.BILINEAR
。fill (序列 或 数字, 可选) – 变换后图像外部区域的像素填充值。如果给定一个数字,则该值将分别用于所有波段。
使用
RandAugment
的示例