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

SOFT:具有线性复杂度的无Softmax Transformer

SOFT: Softmax-free Transformer with Linear Complexity

Fudan University(复旦大学);University of Surrey(萨里大学);Huawei Noah’s Ark Lab(华为诺亚方舟实验室)

Jiachen Lu, Jinghan Yao, Junge Zhang, Xiatian Zhu, Hang Xu, Weiguo Gao, Chunjing Xu, Tao Xiang, Li Zhang

摘要:

视觉Transformer(ViTs)通过逐块图像标记化以及自我注意力,推动了各种视觉识别任务的最新技术。然而,自注意模块的使用导致计算和存储器使用的二次复杂度。在自然语言处理中,已经进行了各种尝试来近似具有线性复杂度的自注意计算。然而,在这项工作中的深入分析表明,他们要么是理论上有缺陷的或经验无效的视觉识别。我们进一步确定,它们的局限性根源于在近似过程中保持softmax自我注意力。具体地说,传统的自我注意力是通过标准化标记特征向量之间的缩放点积来计算的。保持这种softmax操作对后续的线性化工作提出了挑战。基于这种见解,首次提出了一种无softmax的Transformer或SOFT。为了消除自注意中的softmax,使用高斯核函数代替点积相似性,而无需进一步归一化。这使得完全自注意矩阵能够通过低秩矩阵分解来近似。近似的鲁棒性是通过使用牛顿-拉夫森方法计算其Moore-Penrose逆来实现的。在ImageNet上进行的大量实验表明,我们的SOFT显著提高了现有ViT变体的计算效率。重要的是,在线性复杂度下,SOFT中允许更长的令牌序列,从而在准确性和复杂度之间实现更好的权衡。

英文摘要:

Vision transformers (ViTs) have pushed the state-of-the-art for various visual recognition tasks by patch-wise image tokenization followed by self-attention. However, the employment of self-attention modules results in a quadratic complexity in both computation and memory usage. Various attempts on approximating the self-attention computation with linear complexity have been made in Natural Language Processing. However, an in-depth analysis in this work shows that they are either theoretically flawed or empirically ineffective for visual recognition. We further identify that their limitations are rooted in keeping the softmax self-attention during approximations. Specifically, conventional self-attention is computed by normalizing the scaled dot-product between token feature vectors. Keeping this softmax operation challenges any subsequent linearization efforts. Based on this insight, for the first time, a softmax-free transformer or SOFT is proposed. To remove softmax in self-attention, Gaussian kernel function is used to replace the dot-product similarity without further normalization. This enables a full self-attention matrix to be approximated via a low-rank matrix decomposition. The robustness of the approximation is achieved by calculating its Moore-Penrose inverse using a Newton-Raphson method. Extensive experiments on ImageNet show that our SOFT significantly improves the computational efficiency of existing ViT variants. Crucially, with a linear complexity, much longer token sequences are permitted in SOFT, resulting in superior trade-off between accuracy and complexity.

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

↑