Standard Vision Transformers (ViT) have revolutionized computer vision by applying the Transformer architecture to image patches. However, they suffer from a significant computational bottleneck: unlike Convolutional Neural Networks (CNNs), standard ViTs typically maintain a constant sequence length throughout all layers. This paper introduces Hierarchical Visual Transformers (HVT), a novel architecture that incorporates hierarchical pooling to progressively reduce sequence length, enhancing both performance and scalability.
The Challenge of Fixed-Length Transformers
The primary efficiency issue in standard ViTs is the maintenance of a full-length sequence of image patches from the input layer to the final classification head. This "fixed-length" approach leads to two main drawbacks:
- Computational Redundancy: In deeper layers, many tokens represent redundant spatial information, yet the model continues to process them with full attention complexity.
- Lack of Multi-scale Representation: Standard ViTs miss the hierarchical feature extraction—moving from local edges to global shapes—that has been a cornerstone of successful CNN designs.
Methods: Hierarchical Pooling and Scaling
The HVT architecture addresses these issues by partitioning Transformer blocks into multiple stages. Between these stages, a 1D max pooling operation is applied to the token sequence. This effectively "downsamples" the internal representation, reducing the number of tokens as the network goes deeper.
Key architectural modifications include:
- Learnable Positional Embeddings: Since pooling alters the sequence length, HVT introduces fresh learnable positional embeddings after each pooling layer to maintain spatial awareness.
- Global Average Pooling (GAP): The traditional
[CLS]token is replaced. Instead, the model applies GAP to the final set of tokens, feeding the resulting vector into the MLP head. This "collective wisdom" approach was found to be more robust than relying on a single trainable token. - FLOP Re-investment: By reducing the sequence length, HVT significantly lowers the computational cost (FLOPs) of deeper layers. The authors use these "saved" FLOPs to scale the model's width (embedding dimensions) or depth (number of layers), creating a more powerful model within the same computational budget.
Key Results and Efficiency
The HVT framework demonstrates superior scaling properties compared to both standard ViTs (like DeiT) and traditional CNNs (like ResNet).
On the ImageNet-1K benchmark, the "Scale HVT-Ti-4" model achieved a 75.23% Top-1 accuracy. This represents a 3.03% improvement over the baseline DeiT-Ti model, despite both models operating within a similar computational footprint of approximately 1.3G FLOPs. Furthermore, hierarchical pooling acts as a regularizer on smaller datasets like CIFAR-100, preventing the model from overfitting on redundant spatial details.
Conclusion
Hierarchical Visual Transformers bridge the gap between the global modeling capabilities of Transformers and the efficient, multi-scale nature of CNNs. By progressively pooling tokens, HVT achieves a better accuracy-to-computation trade-off, paving the way for more efficient large-scale vision models. Future work may extend these principles to 2D pooling and dense prediction tasks like object detection.
Summary updated