Abstract
The standard "patch-and-process" approach in Vision Transformers (ViTs) often disrupts the natural continuity of images and introduces computational redundancy. We introduce the Pattern Transformer (Patternformer), a novel architecture that replaces rigid spatial patches with semantically meaningful "patterns." By utilizing a CNN-based tokenizer where feature channels serve as visual tokens, Patternformer preserves structural integrity and achieves significant performance gains on datasets such as CIFAR-100 and ImageNet-1K.
Introduction: Beyond the Grid
Since the introduction of the Vision Transformer (ViT), the dominant paradigm for image processing has been "patchification"—dividing an image into a fixed grid of squares (e.g., 16x16). While effective, this method treats images as collections of arbitrary blocks rather than coherent semantic structures. The Pattern Transformer (Patternformer) challenges this convention by proposing that "patterns," not patches, are the fundamental units of visual information.
The Problem with Rigid Patches
The authors identify two primary weaknesses in the standard patch-based approach:
- Structural Collapse: Rigid grids frequently bisect objects. A bird's wing or a car's wheel might be split across multiple tokens, forcing the Transformer to reconstruct basic geometry before it can understand semantics.
- High Redundancy: In most natural images, a large portion of the grid consists of uninformative background. Processing these patches consumes the same computational budget as processing the primary subject, leading to inefficiency.
The Patternformer Architecture
The core of the Patternformer is the Pattern Embedding layer, which shifts the focus from spatial locations to semantic channels.
The Heavy Tokenizer
Instead of a simple linear projection, Patternformer employs a full ResNet as a "Heavy Tokenizer." This pre-processes the image to extract high-level features that are more semantically rich than raw pixels.
Channels as Visual Words
In a traditional CNN, different feature channels often specialize in detecting specific concepts (e.g., textures, edges, or specific object parts). Patternformer treats each of these channels as a single token. This mirrors Natural Language Processing (NLP), where tokens represent abstract concepts (words) rather than physical locations on a page.
Grafting and Global Receptive Field
To integrate the CNN with the Transformer, the authors "graft" the architectures. Unlike previous hybrid models that maintain spatial tokens, Patternformer flattens spatial dimensions and treats the channel dimension as the sequence length. Because each channel is derived from the entire image via the CNN, every token fed into the Transformer possesses a "global" view from the outset, rather than being restricted to a local 16x16 patch.
Experimental Results
The model was evaluated on CIFAR-10, CIFAR-100, and ImageNet-1K to test its scalability and learning efficiency.
- CIFAR Performance: The Res50-ViTB variant reached 84.96% accuracy on CIFAR-100, a substantial improvement over standard ResNet50 (61.7%) and other specialized models like CCT (82.72%).
- ImageNet Efficiency: The "Efficient-T" configuration achieved 75.4% accuracy with only 11.9M parameters, outperforming DeiT-Ti and PVT-Ti while maintaining a lower computational footprint (GFLOPs).
- Interpretability: Visualizations confirm that pattern tokens are semantically consistent. Specific tokens consistently activate on foreground objects across different images, while others focus on background elements, demonstrating that the model separates semantic components effectively.
Discussion and Future Work
Patternformer demonstrates that semantic tokens are more robust to transformations like cropping or rotation than spatial patches. However, the model's performance is heavily dependent on the quality of the CNN tokenizer; a "lightweight" tokenizer often results in a performance drop that the Transformer cannot easily rectify.
Future research will focus on optimizing the balance between CNN depth and Transformer layers, as well as extending the "Pattern Embedding" concept to dense prediction tasks like object detection and semantic segmentation, where spatial localization remains a critical challenge.
Summary updated