TensorFlow 2 中的组转换

Group Conv in TensorFlow 2

TensorFlow2.x是否支持组卷积?
看到很多posts/blogs/tutorials说TensorFlow不支持,也看到一些帖子说tf.keras.layers.DepthwiseConv2D相当于group convolution。但是,我注意到tf.keras.layers.Conv2d中有一个group参数,这是不是很多论文(比如ResNeXt论文)中描述的group convolution?还是我理解错了?
任何帮助和解释都会很棒!

编辑:group conv(第三个)和等效parrellel conv(前两个)的示例。 ResNeXt 论文中的示例

pytorch 中深度为 4 的 32 组的组转换,这意味着总输出通道为 128:
torch.nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3,3), groups=32)

更具体地说,一个由n组和深度为d的输入通道i组成的组conv将把i个输入通道分成n个大小相等的组,每组将是一个具有相同内核大小的普通卷积,步幅为i/n 个通道作为输入,d 个通道作为输出。所有组的输出将被连接成n*d个通道,并作为输入传递给下一层。

是的,tensorflow 确实支持直接使用 groups 参数的 Group Conv。来自 TF2 官方文档中的Conv2D arguments

groups: A positive integer specifying the number of groups in which the input is split along the channel axis. Each group is convolved separately with filters / groups filters. The output is the concatenation of all the groups results along the channel axis. Input channels and filters must both be divisible by groups.

Tensorflow 2 绝对不支持分组卷积!

虽然文档声称 tf.keras.layers.Conv2D 支持它作为 'groups' 参数,但当您尝试它时,您会收到经常报告的错误:

“UnimplementedError: Fused conv 实现目前不支持分组卷积。”

自 2019 年以来已多次报告此错误。

在tf.keras.layers.DepthwiseConv2D.

中单独支持深度卷积的特殊情况,其中组数等于通道数