MLP Can Be A Good Transformer Learner
Sihao Lin, Pumeng Lyu, Dongrui Liu, Tao Tang, Xiaodan Liang, Andy Song, Xiaojun Chang
TL;DR
The paper addresses the high computational and memory costs of Vision Transformers by identifying uninformative attention layers through an entropy-based criterion. It introduces NOSE, an entropy-guided selection strategy using transfer entropy to pick attention layers with minimal impact on the final output, and a dilution learning technique to degenerate these layers into identical mappings that are absorbed by subsequent MLPs. Across ImageNet-1k, ADE20k, and CIFAR-100, the method removes up to 40–50% of attention layers in DeiT-B (and other backbones) with no accuracy loss and notable gains in throughput and memory efficiency. The work also analyzes feature expressivity via frequency-domain methods, showing enhanced high-frequency information and generalization, and provides code and supplementary materials to facilitate adoption and further study.
Abstract
Self-attention mechanism is the key of the Transformer but often criticized for its computation demands. Previous token pruning works motivate their methods from the view of computation redundancy but still need to load the full network and require same memory costs. This paper introduces a novel strategy that simplifies vision transformers and reduces computational load through the selective removal of non-essential attention layers, guided by entropy considerations. We identify that regarding the attention layer in bottom blocks, their subsequent MLP layers, i.e. two feed-forward layers, can elicit the same entropy quantity. Meanwhile, the accompanied MLPs are under-exploited since they exhibit smaller feature entropy compared to those MLPs in the top blocks. Therefore, we propose to integrate the uninformative attention layers into their subsequent counterparts by degenerating them into identical mapping, yielding only MLP in certain transformer blocks. Experimental results on ImageNet-1k show that the proposed method can remove 40% attention layer of DeiT-B, improving throughput and memory bound without performance compromise. Code is available at https://github.com/sihaoevery/lambda_vit.
