HydraViT:堆叠注意力头实现可扩展视觉Transformer
HydraViT: Stacking Heads for a Scalable ViT
AI总结:
针对ViT部署需多模型的局限,HydraViT通过训练时动态调整嵌入维度和注意力头数量生成多子网络,实现可扩展ViT,在ImageNet-1K上相同资源下准确率提升显著,适配多样硬件环境。
摘要:
视觉Transformer(ViT)的架构,尤其是多头注意力(MHA)机制,对硬件有极高需求。在移动设备等不同资源约束的设备上部署ViT需要不同大小的多个模型,但该方法存在局限性,例如需分别训练和存储每个所需模型。本文提出HydraViT,一种通过堆叠注意力头实现可扩展ViT的新方法。训练期间,通过在每一层反复改变嵌入维度大小及其对应的MHA注意力头数量,HydraViT诱导出多个子网络,从而在保持性能的同时实现跨多种硬件环境的适应性。实验结果表明,HydraViT能有效实现包含多达10个子网络的可扩展ViT,覆盖广泛的资源约束场景;在ImageNet-1K上,相同GMACs下准确率提升高达5个百分点,相同吞吐量下准确率提升高达7个百分点,是硬件多样性或随时间变化场景的有效解决方案。源代码见https://github.com/ds-kiel/HydraViT。
英文摘要:
The architecture of Vision Transformers (ViTs), particularly the Multi-head Attention (MHA) mechanism, imposes substantial hardware demands. Deploying ViTs on devices with varying constraints, such as mobile phones, requires multiple models of different sizes. However, this approach has limitations, such as training and storing each required model separately. This paper introduces HydraViT, a novel approach that addresses these limitations by stacking attention heads to achieve a scalable ViT. By repeatedly changing the size of the embedded dimensions throughout each layer and their corresponding number of attention heads in MHA during training, HydraViT induces multiple subnetworks. Thereby, HydraViT achieves adaptability across a wide spectrum of hardware environments while maintaining performance. Our experimental results demonstrate the efficacy of HydraViT in achieving a scalable ViT with up to 10 subnetworks, covering a wide range of resource constraints. HydraViT achieves up to 5 p.p. more accuracy with the same GMACs and up to 7 p.p. more accuracy with the same throughput on ImageNet-1K compared to the baselines, making it an effective solution for scenarios where hardware availability is diverse or varies over time. Source code available at https://github.com/ds-kiel/HydraViT.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。