RandomInvert¶ class torchvision.transforms.RandomInvert(p=0.5)[source]¶ 以給定的機率隨機反轉給定影像的顏色。如果 img 是 Tensor,期望其格式為 […, 1 或 3, H, W],其中 … 表示可以有任意數量的前導維度。如果 img 是 PIL Image,期望其模式為 “L” 或 “RGB”。 引數: p (float) – 影像顏色被反轉的機率。預設值為 0.5 使用 RandomInvert 的示例 變換示例 變換示例 forward(img)[source]¶ 引數: img (PIL Image 或 Tensor) – 待反轉的影像。 返回: 隨機顏色反轉後的影像。 返回型別: PIL Image 或 Tensor