Papers
Topics
Authors
Recent
Search
2000 character limit reached

H3Former: Hypergraph-Based Visual Classification

Updated 9 January 2026
  • The paper introduces H3Former, a framework that leverages hypergraph-based semantic token aggregation and hyperbolic hierarchical contrastive loss to distinguish subtle inter-class differences in fine-grained visual tasks.
  • It employs a Swin-B Transformer backbone with multi-scale context generation and a Semantic-Aware Aggregation Module (SAAM) to capture high-order semantic dependencies from regional features.
  • Experimental evaluations on benchmark FGVC datasets demonstrate that integrating SAAM and HHCL significantly boosts classification accuracy, outperforming existing approaches.

H3Former is a framework designed for fine-grained visual classification (FGVC), targeting the challenge of distinguishing subtle inter-class differences and managing large intra-class variation. The architecture introduces hypergraph-based semantic-aware token aggregation using multi-scale context and incorporates a hyperbolic hierarchical contrastive loss to enforce semantic structure during representation learning. H3Former achieves state-of-the-art classification performance on multiple benchmark FGVC datasets using a single Transformer backbone and standard augmentation protocols (Zhang et al., 13 Nov 2025).

1. Architectural Overview

H3Former operates on input images resized to 448×448, utilizing a Swin-B Transformer backbone pretrained on ImageNet (22K for CUB/NA-Birds/Flowers, 1K for Dogs). Feature tokens are extracted at each of the four hierarchically organized Swin stages:

Xs∈RNs×Cs,s=1,…,4X_s \in \mathbb{R}^{N_s \times C_s},\quad s = 1,\ldots,4

where NsN_s and CsC_s are the number of spatial patches and channel dimension at stage ss, respectively.

The dataflow proceeds as follows:

  1. Multi-scale Context Generation Module (CGM): Each XsX_s is aggregated into three context vectors:
    • fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))
    • fsmax=Linear(MaxPool(Xs))f_s^{max} = \text{Linear}(\text{MaxPool}(X_s))
    • fsattn=Linear(∑iVs[i]Xs[i])f_s^{attn} = \text{Linear}\left(\sum_i V_s[i] X_s[i]\right), where VsV_s is derived from self-attention.
  2. The twelve vectors ($4$ stages NsN_s0 NsN_s1 stats) are concatenated:

NsN_s2

  1. NsN_s3 is input to the Semantic-Aware Aggregation Module (SAAM), which builds and convolves a multi-scale weighted hypergraph over token features to yield region-level aggregates.
  2. A gated residual fusion combines the original and hypergraph-refined tokens, followed by global pooling and a classifier.
  3. Simultaneously, M region features are extracted for construction of a semantic hierarchy and computation of hyperbolic hierarchical contrastive loss (HHCL).

2. Semantic-Aware Aggregation Module (SAAM)

2.1 Multi-scale Weighted Hypergraph Construction

The context matrix NsN_s4 is split into NsN_s5 groups along the channel axis: NsN_s6 for NsN_s7. Each group is mapped by a shared MLP NsN_s8, then combined with a learnable prototype NsN_s9 to produce hyperedge prototypes:

CsC_s0

Final-stage tokens CsC_s1 are projected to CsC_s2 using a learned matrix CsC_s3, and token-hyperedge affinity is softmax-normalized:

CsC_s4

2.2 Hypergraph Convolution and Residual Fusion

The hypergraph convolution propagates information via a vertex-edge-vertex (V→E→V) message passing:

  1. Aggregate to hyperedges: CsC_s5
  2. Propagate back to nodes: CsC_s6
  3. Residual combination with a learned gate CsC_s7: CsC_s8

This mechanism enables high-order semantic dependencies to be captured across spatial regions for region-level discrimination.

3. Hyperbolic Hierarchical Contrastive Loss (HHCL)

3.1 Hyperbolic Embedding via the Lorentz Model

Region features (from SAAM) are embedded on the CsC_s9-dimensional hyperboloid:

ss0

with Lorentzian inner product ss1. The exponential map from Euclidean ss2 is:

ss3

The hyperbolic distance is defined as ss4.

3.2 Semantic Hierarchy and Contrastive Losses

Region features are recursively merged using a similarity-based agglomeration operator to form a semantic tree of ss5 levels. The joint distance between features ss6 is:

ss7

At each tree level, a supervised contrastive loss is applied:

ss8

where ss9 denotes positive instances (same class), XsX_s0 is a temperature parameter.

A hyperbolic partial-order loss enforces locality between parents and children in the semantic tree:

XsX_s1

The full HHCL is XsX_s2. The final objective is XsX_s3, combining classification and hierarchy-based structure loss.

4. Experimental Evaluation

H3Former is evaluated on four FGVC benchmarks: CUB-200-2011, NA-Birds, Stanford-Dogs, and Oxford-Flowers-101. Images are processed into XsX_s4 tokens (stride 14). The Swin-B backbone is configured with dimensions XsX_s5, heads XsX_s6 across 12 layers. SAAM uses XsX_s7 hyperedges, prototype dimension XsX_s8; HHCL uses curvature XsX_s9, fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))0, fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))1, fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))2, and fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))3 hierarchical levels.

Top-1 Accuracy Comparisons on CUB-200-2011

Method CUB-200-2011
TransFG (Swin-B) 91.7%
IELT (ViT-B) 91.8%
SR-GNN (Xception) 91.9%
H³Former 92.7%

Similar performance gains (+0.7% to +4.7%) are reported on the other datasets, with H3Former achieving 99.7% on Flowers-101.

Ablation Results

Model Variant CUB Dogs
w/o SAAM & HHCL 90.9% 91.1%
+SAAM only 92.5% 95.2%
+HHCL only 91.2% 92.6%
SAAM + HHCL 92.7% 95.8%

The ablations highlight the contribution of both SAAM and HHCL to classification accuracy.

5. Visualization and Qualitative Insights

Hyperedge visualizations: By projecting affinity values fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))4 back onto the spatial layout, heatmaps demonstrate that different hyperedges consistently attend to semantically meaningful parts (e.g., beak, wing, tail, feet of birds) across instances, evidencing robust part discovery even under occlusion.

t-SNE visualizations: When only HHCL is applied, embedding clusters show improved compactness. With only SAAM, discrimination between regions is enhanced. Using both modules yields well-separated, compact clusters that align with class boundaries, signifying improved representation learning for fine-grained discrimination.

6. Technical Innovations and Significance

H3Former’s core innovation lies in two interlocking mechanisms:

  1. Semantic-Aware Aggregation Module (SAAM): A dynamic, multi-scale, weighted hypergraph mechanism that consolidates token representations into region-level features through high-order message passing, enabling richer semantic contextualization.
  2. Hyperbolic Hierarchical Contrastive Loss (HHCL): A dual-space (Euclidean and Lorentz hyperbolic) contrastive approach that leverages a semantic part hierarchy to simultaneously increase inter-class separation, enforce intra-class consistency, and preserve part–whole relationships.

This approach circumvents the limitations of previous feature selection and region proposal pipelines, offering a framework for token-to-region aggregation that is both semantically expressive and computationally tractable. The design achieves state-of-the-art results on established FGVC datasets using standard backbones and data augmentation (Zhang et al., 13 Nov 2025).

7. Hyperparameter Choices and Implementation Details

Key implementation hyperparameters:

  • Backbone: Swin-B Transformer, {128,256,512,1024}-dim embeddings, {4,8,16,32} heads, 12 layers.
  • SAAM: fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))5 hyperedges, prototype dimension fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))6, MLP fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))7 with 2 layers.
  • HHCL: Lorentz curvature fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))8, balancing parameters fsavg=Linear(AvgPool(Xs))f_s^{avg} = \text{Linear}(\text{AvgPool}(X_s))9, fsmax=Linear(MaxPool(Xs))f_s^{max} = \text{Linear}(\text{MaxPool}(X_s))0, fsmax=Linear(MaxPool(Xs))f_s^{max} = \text{Linear}(\text{MaxPool}(X_s))1, hierarchy depth fsmax=Linear(MaxPool(Xs))f_s^{max} = \text{Linear}(\text{MaxPool}(X_s))2 (ratios 16, 8, 4, 1).

Performance is maximized with these settings, as confirmed via ablation. The entire method is compatible with a single backbone and requires no explicit part or region annotations, indicating efficiency in practical deployment (Zhang et al., 13 Nov 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

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 H3Former.