AutoAugment¶
- class torchvision.transforms.v2.AutoAugment(policy: AutoAugmentPolicy = AutoAugmentPolicy.IMAGENET, interpolation: Union[InterpolationMode, int] = InterpolationMode.NEAREST, fill: Union[int, float, Sequence[int], Sequence[float], None, dict[Union[type, str], Union[int, float, collections.abc.Sequence[int], collections.abc.Sequence[float], NoneType]] = None)[source]¶
AutoAugment 数据增强方法,基于 “AutoAugment: Learning Augmentation Strategies from Data”。
此转换仅适用于图像和视频。
如果输入是
torch.Tensor
,它应该是torch.uint8
类型,并且其形状预计为 […, 1 或 3, H, W],其中 … 表示任意数量的前导维度。如果 img 是 PIL Image,它应处于 “L” 或 “RGB” 模式。- 参数:
policy (AutoAugmentPolicy, optional) – 由
torchvision.transforms.autoaugment.AutoAugmentPolicy
定义的期望策略枚举。默认为AutoAugmentPolicy.IMAGENET
。interpolation (InterpolationMode, optional) – 由
torchvision.transforms.InterpolationMode
定义的期望插值枚举。默认为InterpolationMode.NEAREST
。如果输入是 Tensor,仅支持InterpolationMode.NEAREST
和InterpolationMode.BILINEAR
。fill (sequence 或 number, 可选) – 转换后图像外部区域的像素填充值。如果给定一个数字,则该值分别用于所有通道。
使用
AutoAugment
的示例- static get_params(transform_num: int) tuple[int, torch.Tensor, torch.Tensor] [source]¶
获取 autoaugment 变换的参数
- 返回:
autoaugment 变换所需的参数