Papers
Topics
Authors
Recent
Search
2000 character limit reached

Multi-Scale Weight-Sharing Window Attention

Updated 16 December 2025
  • Multi-scale weight-sharing window attention is a novel technique that partitions transformer heads into groups with varying window sizes to capture both local and global features.
  • It employs a dynamic weight-sharing module that fuses multi-scale representations adaptively, ensuring efficient computation and robust hierarchical context capture.
  • Empirical benchmarks on ImageNet, ADE20K, and COCO confirm consistent performance improvements over standard window attention methods with minimal additional resource cost.

Multi-scale weight-sharing window attention is a mechanism within vision transformers that generalizes local windowed self-attention by partitioning attention heads into groups operating on windows of multiple spatial scales, then dynamically fusing these multi-scale representations via learnable weight-sharing modules. This approach, notably implemented in Dynamic Window Vision Transformer (DW-ViT) and aligned to Lawin Transformer’s large-window attention, provides enhanced capability for capturing hierarchical context with computational efficiency, yielding consistent empirical improvements on image classification, segmentation, and detection benchmarks (Ren et al., 2022, Yan et al., 2022).

1. Mathematical Formulation of Multi-Scale Window Attention

Let X∈RH×W×CX\in\mathbb{R}^{H\times W\times C} be the input feature map. In DW-ViT, the total hh attention heads are split into SS groups; each group ii operates with window size wiw_i. Each group contains Hi=h/SH_i=h/S heads, and per-head hidden dimension is dk=C/hd_k=C/h. The feature map is reshaped as X^∈Rh×H×W×dk\hat{X}\in\mathbb{R}^{h\times H\times W\times d_k} and divided along the head dimension into SS disjoint chunks X^i∈RH×W×(Hidk)\hat{X}_i\in\mathbb{R}^{H\times W\times (H_i d_k)}. Each hh0 is partitioned into non-overlapping windows of size hh1 (hh2, hh3).

Within each window hh4 for head group hh5, projections are computed: hh6

Attention is computed for each scale using relative bias: hh7 where hh8 indexes relative spatial displacements within the window from the parameter tensor hh9.

Post-attention, all SS0 (unwindowed to SS1) are concatenated along channel dimension: SS2

2. Dynamic Weight-Sharing Fusion Mechanism

After per-scale attention, dynamic multi-scale fusion (“DMSW” module) selects and mixes scale features adaptively:

  • Fuse: Global average pooling SS3; non-linear projection layers SS4.
  • Select: Soft-attention scores SS5 over scales; SS6, SS7.
  • Weighted sum & residual: SS8; residual SS9 restoring spatial dimension.

Parameters (ii0) are shared over spatial positions but not across scales. By construction, ii1.

3. Integration into Transformer Architectures

Each block of DW-ViT replaces standard MSA with the MSW-MSA and DMSW fusion. The assignment of window sizes to head groups is resolution dependent, with empirically chosen lists (e.g., [7,14,21]) adapting at each stage (Ren et al., 2022). DMSW combines multi-scale tokens and outputs them after residual fusion.

Example block pseudocode:

wiw_i7

In Lawin Transformer, large-window attention is employed within a spatial pyramid pooling framework (LawinASPP), using multi-scale receptive fields (e.g., ii2) on top of hierarchical ViT encoders (Yan et al., 2022).

4. Computational Complexity and Parameterization

For DW-ViT MSW-MSA, the computational cost at each block is: ii3

ii4

ii5

Overhead relative to single window is ii6 in ii7, with parameters increasing by ii8 for DMSW layers and ii9 bias matrices wiw_i0. In Lawin Transformer, large-window attention branches induce a cost difference of wiw_i1 per branch but total cost is comparable to stacked local windows, remaining efficient for practical wiw_i2 (Yan et al., 2022).

5. Empirical Benchmark Performance

Multi-scale weight-sharing window attention consistently outperforms single-scale window transformers with minor resource increase.

Model Params (M) FLOPs (G) ImageNet Top-1 (%) ADE20K mIoU (%) COCO AP_box / AP_mask
Swin-T [std] 28 4.5 81.3 44.5 46.0 / 41.6
DW-T 30 5.2 82.0 (+0.7) 45.7 (+1.2) 46.7 / 42.4 (+0.7/+0.8)
Swin-B [std] 88 15.4 83.3 48.1 48.5 / 43.4
DW-B 91 17.0 83.8 (+0.5) 48.7 (+0.6) 49.2 / 44.0 (+0.7/+0.6)

Lawin Transformer with large-window attention and multi-scale fusion yields ablation results indicating that each multi-scale branch (e.g., wiw_i3) and global pooling contribute wiw_i4-wiw_i5 absolute mIoU (Yan et al., 2022). Removal of position-mixing MLPs results in up to wiw_i6 performance drops, emphasizing their necessity for restoring fine spatial detail.

6. Relationship to Large-Window Attention and Multi-scale Pooling

Large-window attention within Lawin Transformer (Yan et al., 2022) operates by extending each window’s context via larger area queries—with average pooling and token-mixing MLP restoring spatial fidelity—yielding effective multi-scale context representations. Weight-sharing is realized across all windows at a given scale, and distinct trainable branches handle multi-scale aggregation. LawinASPP decoder generalizes atrous spatial pyramid pooling to multi-scale transformer attention, achieving efficient semantic segmentation.

In Lawin’s architecture, multi-level features (from hierarchical transformer encoder) are aggregated at several strides and fed through branches with receptive fields matching multiple scales and global context, each fused by simple concatenation and linear projection.

7. Context and Implications for Vision Transformers

Multi-scale weight-sharing window attention enables transformer backbones to capture both local and global dependencies with flexible windowing and efficient computation. The construction supports seamless integration into Swin-style architectures, scalable adaptation to input resolutions, and consistent empirical gains across image understanding tasks. This suggests that dynamic multi-scale modeling with adaptive fusion offers a generic replacement for fixed window transformers and convolutional pooling layers, while maintaining resource efficiency and deployment compatibility (Ren et al., 2022, Yan et al., 2022).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Multi-Scale Weight-Sharing Window Attention.