tensorflow - TensorFlow 2 中的分组转换

标签 tensorflow keras conv-neural-network tensorflow2

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

编辑:组转换(第三个)和等效并行转换(前两个)的示例。 ResNeXt 论文中的示例 group conv

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/

相关文章:

tensorflow - CNN 的模型架构设计

image - jpeg 压缩会影响使用卷积神经网络的训练和分类吗

tensorflow - 如何修复错误 "object has no attribute ' _output_tensor_cache'"?

tensorflow - TensorFlow 的 model.fit() 函数中的 batchSize 是多少?

python - 从 Keras 多类模型中获取混淆矩阵

android - 如何保存图像分类模型并将其用于 android

image-processing - Caffe的卷积层中bias_filler类型 "constant"的默认值是多少?

python - HuggingFace BERT `inputs_embeds` 给出了意想不到的结果

python - Tensorflow:Sigmoid交叉熵损失不会强制网络输出为0或1

python - 提取 3 个嵌入层的 Keras 连接层,但它是一个空列表