快捷方式

permute_channels

torchvision.transforms.v2.functional.permute_channels(inpt: Tensor, permutation: List[int]) Tensor[原始碼]

根據給定的置換調整輸入的通道順序。

此函式支援普通的 TensorPIL.Image.Image,以及 torchvision.tv_tensors.Imagetorchvision.tv_tensors.Video

示例

>>> rgb_image = torch.rand(3, 256, 256)
>>> bgr_image = F.permute_channels(rgb_image, permutation=[2, 1, 0])
引數:

permutation (List[int]) –

輸入通道索引的有效置換。列表中元素的索引決定輸入中的通道索引,值決定輸出中的通道索引。例如,permutation=[2, 0 , 1]

  • 會取 ìnpt[..., 0, :, :] 並將其放置在 output[..., 2, :, :]

  • ìnpt[..., 1, :, :] 並將其放置在 output[..., 0, :, :],以及

  • ìnpt[..., 2, :, :] 並將其放置在 output[..., 1, :, :]

丟擲:

ValueError – 如果 len(permutation) 與輸入的通道數不匹配。

文件

查閱全面的 PyTorch 開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源