TensorFlow2.x支持群卷积吗?
我看到很多帖子/博客/教程说TensorFlow不支持,也看到一些帖子说tf.keras.layers.DepthwiseConv2D相当于组卷积。但是,我注意到tf.keras.layers.Conv2d中有一个组参数,这就是很多论文(例如ResNeXt论文)中描述的组卷积吗?还是我理解错了?
任何帮助和解释都会很棒!
编辑:组转换(第三个)和等效并行转换(前两个)的示例。 ResNeXt 论文中的示例
pytorch中深度为4的32组的组卷积,这意味着总输出 channel 为128:
torch.nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3,3), groups=32)
更具体地说,一个包含 n 个组、深度为 d、输入 channel 为 i 的组卷积会将 i 个输入 channel 分成 n 个大小相等的组,每个组将是具有相同内核大小的普通卷积,步长为 i/n 个 channel 作为输入,d 个 channel 作为输出。所有组的输出将连接成 n*d 个 channel 并传递到下一层作为输入。
最佳答案
是的,tensorflow确实支持直接使用groups
参数进行Group Conv。来自 Conv2D arguments
TF2 官方文档中:
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 - TensorFlow 2 中的分组转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66857534/