论文:https://arxiv.org/abs/2103.14899
代码:https://github.com/IBM/CrossViT
这是来自于美国 MIT-IBM Watson AI实验室在ICCV2021上的工作,研究动机是:how to learn multi-scale feature representation in Transformer models.
该方法的想法非常直接,构建两个网络,分别提取 small patch 特征和 large patch 特征,然后将两个网络进行 cross-attention 融合,如图下图所示:
该方法关键的部分是如何将两个网络的结果进行融合,作者探索了4种不同的融合策略:
- All-attention fusion:两个网络的 token 全部融合。
- Class-token fusion:class-token是网络的全局表示,将两个网络的 class token 融合作为两个分支后续的 class token。
- Pairwise fusion:对应空间位置的 token 进行融合。
- Cross-attention fusion:来自一个分支的 class token 和来自另一个分支的 class token 融合。
经过实验,作者选择 cross-attention 作为融合的方式,该模块细节如下图所示(以大分支为例)。具体过程也比较容易理解 ,这里不再多说。
实验部分,作者分析的非常详细。说几个有趣的地方:左右两个网络,很自然的就会想到,到底哪个网络发挥的作用更大?表7中的 B 行提升了 small 网络的特征维度,C行中提升了 small 网络 transformer block 的数量,可以看出,C行的性能提升更明显。作者指出:L-branch has the main role to extract features while S-branch only provides additional information; thus, a light-weight branch is enough。
表中的E行是进行将 multi-scale transformer block重复6次,D行是只重复3次但是每次里面 cross-attention计算2次,结果表明计算效率更高的D行效果略好。作者的解释是:Patch token from the other branch is untouched, and the advantages from stacking more than one cross-attention is small as cross-attention is a linear operation without any nonlinearity function. Likewise, using more multi-scale transformer encoders also does not help in performance which is the similar case to increase the capacity of S-branch.