通道混洗¶
- class torch.nn.ChannelShuffle(groups)[源代码]¶
分割并重新排列张量中的通道。
此操作将形状为 的张量中的通道分成 g 组,并将其重新排列为 , 同时保持原始张量形状。
- Parameters
groups (int) – 要划分的通道组数。
示例:
>>> channel_shuffle = nn.ChannelShuffle(2) >>> input = torch.randn(1, 4, 2, 2) >>> print(input) [[[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]], [[13, 14], [15, 16]], ]] >>> output = channel_shuffle(input) >>> print(output) [[[[1, 2], [3, 4]], [[9, 10], [11, 12]], [[5, 6], [7, 8]], [[13, 14], [15, 16]], ]]