[论文解读] BatchFormer: Learning to Explore Sample Relationships for Robust Representation Learning
BatchFormer 引入了一个即插即用的 Transformer 模块,该模块在批量维度上运行,以在训练期间学习样本间关系,从而实现跨样本的知识迁移——尤其在低少样本和尾部类别识别中受益显著。通过在模块前后共享分类器,它消除了推理开销,并在无需额外组件的情况下,在长尾识别、零样本学习、域泛化和对比学习任务中实现了最先进性能。
Despite the success of deep neural networks, there are still many challenges in deep representation learning due to the data scarcity issues such as data imbalance, unseen distribution, and domain shift. To address the above-mentioned issues, a variety of methods have been devised to explore the sample relationships in a vanilla way (i.e., from the perspectives of either the input or the loss function), failing to explore the internal structure of deep neural networks for learning with sample relationships. Inspired by this, we propose to enable deep neural networks themselves with the ability to learn the sample relationships from each mini-batch. Specifically, we introduce a batch transformer module or BatchFormer, which is then applied into the batch dimension of each mini-batch to implicitly explore sample relationships during training. By doing this, the proposed method enables the collaboration of different samples, e.g., the head-class samples can also contribute to the learning of the tail classes for long-tailed recognition. Furthermore, to mitigate the gap between training and testing, we share the classifier between with or without the BatchFormer during training, which can thus be removed during testing. We perform extensive experiments on over ten datasets and the proposed method achieves significant improvements on different data scarcity applications without any bells and whistles, including the tasks of long-tailed recognition, compositional zero-shot learning, domain generalization, and contrastive learning. Code will be made publicly available at https://github.com/zhihou7/BatchFormer.
研究动机与目标
- 为解决深度表示学习中的数据稀缺挑战,如长尾类别分布、域偏移和未见类别。
- 克服现有方法仅通过输入或损失函数探索样本关系,而非通过深度神经网络内部结构的局限性。
- 使深度神经网络能够在训练过程中隐式学习并利用每个小批量内样本之间的关系。
- 通过在 BatchFormer 模块前后共享分类器,减少训练-推理差距,从而在推理时可移除该模块。
提出的方法
- 引入 BatchFormer 模块,将小批量中的每个样本视为序列中的一个 token,应用标准 Transformer 编码器以建模样本间关系。
- 将 BatchFormer 应用于批量维度,使每个样本的损失梯度可反向传播至小批量中所有其他样本,从而有效实现虚拟数据增强。
- 在训练期间于 BatchFormer 前后使用共享分类器,以强制实现批量不变的表示学习,并允许在推理时移除该模块。
- 采用平衡交叉熵损失和对比学习目标,以增强特征判别力和泛化能力,尤其对稀有类别有益。
- 利用 Grad-CAM 和梯度分析可视化 BatchFormer 如何增强对相关物体部位的关注并减少虚假相关性。
- 在批量大小、分类器共享和主干网络架构方面进行大量消融实验,以验证设计选择的合理性与鲁棒性。
实验结果
研究问题
- RQ1在小批量内建模样本关系是否能改善数据稀缺下的表示学习?
- RQ2批量 Transformer 模块是否能提升长尾识别中低少样本和尾部类别的特征学习?
- RQ3BatchFormer 模块能否在不修改推理流程的前提下集成到现有模型中?
- RQ4共享分类器机制在基于批量的表示学习中如何缓解训练-推理差距?
- RQ5BatchFormer 在零样本学习、域泛化和对比学习中能在多大程度上提升鲁棒性?
主要发现
- BatchFormer 在超过十个数据集上实现了多个数据稀缺任务的最先进性能,包括长尾识别、零样本学习、域泛化和对比学习。
- 在 ImageNet-LT 上,BatchFormer 在 'All' 类上达到 50.9% 的 top-1 准确率,优于使用共享分类器的基线模型,并显著提升了少样本性能。
- 加入 BatchFormer 的模型收敛更快,仅用 38 个周期即达到 moco-v3 水平的性能,表明训练效率得到提升。
- 消融实验表明,当批量大小低于 128 时,BatchFormer 对批量大小不敏感,且在批量大小为 512 时,对少样本类别表现最佳。
- Grad-CAM 可视化结果证实,BatchFormer 增强了对物体部位的关注,并抑制了复杂场景中对虚假背景的相关性。
- 梯度分析显示,稀有类别对小批量中其他图像的梯度更大,表明其隐式实现了数据增强,从而有利于低少样本学习。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。