随机水平翻转¶ class torchvision.transforms.RandomHorizontalFlip(p=0.5)[source]¶ 以给定的概率随机水平翻转给定的图像。 如果图像是torch张量,则期望其具有[…, H, W]形状,其中…表示任意数量的前导维度。 Parameters: p (float) – 图像被翻转的概率。默认值为0.5 使用 RandomHorizontalFlip 的示例: 开始使用 transforms v2 Getting started with transforms v2 变换的图示 Illustration of transforms Transforms v2: 端到端目标检测/分割示例 Transforms v2: End-to-end object detection/segmentation example 如何使用CutMix和MixUp How to use CutMix and MixUp 如何编写自己的v2转换 How to write your own v2 transforms 如何编写你自己的TVTensor类 How to write your own TVTensor class Torchscript 支持 Torchscript support forward(img)[source]¶ Parameters: img (PIL Image 或 Tensor) – 要翻转的图像。 Returns: 随机翻转的图像。 Return type: PIL 图像或张量