Number of Attention Heads vs Number of Transformer-Encoders in Computer Vision
Tomas Hrycej, Bernhard Bermeitinger, Siegfried Handschuh

TL;DR
This paper investigates how the number of attention heads and transformer encoders affect the performance of Transformer models in computer vision, providing guidelines for optimal architecture choices based on experimental analysis.
Contribution
It offers empirical insights into selecting the number of attention heads and encoders in vision Transformers, emphasizing the importance of parameter overdetermination for good generalization.
Findings
Total parameters should satisfy overdetermination condition.
Multiple low-head transformers are effective for small context images.
High-head transformers are important for context-dependent classification.
Abstract
Determining an appropriate number of attention heads on one hand and the number of transformer-encoders, on the other hand, is an important choice for Computer Vision (CV) tasks using the Transformer architecture. Computing experiments confirmed the expectation that the total number of parameters has to satisfy the condition of overdetermination (i.e., number of constraints significantly exceeding the number of parameters). Then, good generalization performance can be expected. This sets the boundaries within which the number of heads and the number of transformers can be chosen. If the role of context in images to be classified can be assumed to be small, it is favorable to use multiple transformers with a low number of heads (such as one or two). In classifying objects whose class may heavily depend on the context within the image (i.e., the meaning of a patch being dependent on other…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
MethodsAttention Is All You Need · Linear Layer · Position-Wise Feed-Forward Layer · Byte Pair Encoding · Adam · Softmax · Dense Connections · Residual Connection · Absolute Position Encodings · Dropout
