arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2111.11802cs.CVcs.LG
收藏

在单路径中将自注意力剪枝为卷积层

Pruning Self-attentions into Convolutional Layers in Single Path

Monash University(莫纳什大学);The University of Sydney(悉尼大学);Nanyang Technological University(南洋理工大学)

Haoyu He, Jianfei Cai, Jing Liu, Zizheng Pan, Jing Zhang, Dacheng Tao, Bohan Zhuang

AI总结:

本文提出单路径视觉Transformer剪枝方法SPViT,通过MSA与卷积的权重共享和可学习门自动搜索剪枝结构,在ImageNet-1k上实现新SOTA,如为DeiT-B削减52.0% FLOPs并提升0.6% top-1精度。

摘要:

视觉Transformer(ViTs)在各种计算机视觉任务上取得了令人瞩目的性能。然而,利用多头自注意力(MSA)层建模全局相关性带来了两个广为人知的问题:巨大的计算资源消耗,以及建模局部视觉模式时缺乏内在归纳偏置。为解决这两个问题,我们设计了一种简单而有效的方法,称为单路径视觉Transformer剪枝(SPViT),用于高效且自动地将预训练的ViTs压缩为具有适当局部性的紧凑模型。具体来说,我们首先提出了一种新颖的MSA与卷积操作之间的权重共享方案,提供一个单路径空间来编码所有候选操作。通过这种方式,我们将操作搜索问题转化为在每个MSA层中寻找使用哪一子集参数的问题,这显著降低了计算成本和优化难度,并且卷积核可以利用预训练的MSA参数进行良好初始化。基于该单路径空间,我们引入可学习的二值门来编码MSA层中的操作选择。类似地,我们进一步使用可学习门来编码FFN层的细粒度MLP扩展比率。通过这种方式,我们的SPViT优化可学习门,以自动地从庞大且统一的搜索空间中进行探索,并为每个单独的稠密模型灵活调整MSA-FFN剪枝比例。我们在两个具有代表性的ViTs上进行了大量实验,结果表明我们的SPViT在ImageNet-1k上实现了剪枝的新SOTA。例如,我们的SPViT可以为DeiT-B削减52.0%的FLOPs,同时获得令人印象深刻的0.6%的top-1精度提升。源代码可在https://github.com/ziplab/SPViT获取。

英文摘要:

Vision Transformers (ViTs) have achieved impressive performance over various computer vision tasks. However, modeling global correlations with multi-head self-attention (MSA) layers leads to two widely recognized issues: the massive computational resource consumption and the lack of intrinsic inductive bias for modeling local visual patterns. To solve both issues, we devise a simple yet effective method named Single-Path Vision Transformer pruning (SPViT), to efficiently and automatically compress the pre-trained ViTs into compact models with proper locality added. Specifically, we first propose a novel weight-sharing scheme between MSA and convolutional operations, delivering a single-path space to encode all candidate operations. In this way, we cast the operation search problem as finding which subset of parameters to use in each MSA layer, which significantly reduces the computational cost and optimization difficulty, and the convolution kernels can be well initialized using pre-trained MSA parameters. Relying on the single-path space, we introduce learnable binary gates to encode the operation choices in MSA layers. Similarly, we further employ learnable gates to encode the fine-grained MLP expansion ratios of FFN layers. In this way, our SPViT optimizes the learnable gates to automatically explore from a vast and unified search space and flexibly adjust the MSA-FFN pruning proportions for each individual dense model. We conduct extensive experiments on two representative ViTs showing that our SPViT achieves a new SOTA for pruning on ImageNet-1k. For example, our SPViT can trim 52.0% FLOPs for DeiT-B and get an impressive 0.6% top-1 accuracy gain simultaneously. The source code is available at https://github.com/ziplab/SPViT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑