FTCFormer: Fuzzy Token Clustering Transformer for Image Classification

Muyi Bao, Changyu Zeng, Yifan Wang, Zhengni Yang, Zimu Wang, Guangliang Cheng, Jun Qi, Wei WangarXiv 2025 · DOI

TL;DR

This paper introduces FTCFormer, a Vision Transformer that dynamically generates image tokens based on semantic importance rather than fixed spatial grids. By employing a novel Fuzzy Token Clustering and Merging (FTCM) module, FTCFormer achieves improved image classification performance across diverse datasets by better capturing salient features.

What Problem Does This Paper Address?

Vision Transformers (ViTs) have revolutionized computer vision tasks by leveraging self-attention mechanisms. However, standard ViTs typically divide images into uniform, grid-based "tokens," treating all image regions equally. This approach can be inefficient and suboptimal, as it might allocate significant computational resources to less informative areas while neglecting semantically rich regions. Existing hierarchical ViTs often use conventional downsampling methods like MaxPooling, which also fail to prioritize semantic content. While prior work like TCFormer attempted to address this with clustering-based token generation, it suffered from sensitivity to hyperparameters and issues with uneven data distributions. FTCFormer aims to overcome these limitations by introducing a more robust and semantically aware tokenization strategy.

Methods

The core innovation of FTCFormer lies in its Fuzzy Token Clustering and Merging (FTCM) module, which replaces traditional downsampling layers in a hierarchical ViT architecture. FTCM comprises four key stages:

  1. Clustering Center Determination (DPC-FKNN): Instead of the standard Density Peak Clustering with K-Nearest Neighbors (DPC-KNN), FTCFormer uses DPC-FKNN. This method incorporates fuzzy K-nearest neighbors (FKNN) and a distance-based decay to make clustering center selection more robust to outliers, uneven data, and hyperparameter sensitivity (specifically, the K value). A novel fuzzy distance kernel is introduced to weigh contributions from KNN and non-KNN neighbors.
  2. Token Assignment (SCS Metric): To assign non-center tokens to clusters, FTCFormer introduces the Spatial Connectivity Score (SCS). This metric combines the number of Shared Nearest Neighbors (SNN) and the closeness to the KNN set, providing a more context-aware assignment than solely relying on Euclidean distance, which can be problematic in high-dimensional feature spaces.
  3. Token Merging (Cmerge): For merging tokens within a cluster into a single representative token, FTCFormer proposes Channel Merging (Cmerge). This strategy uses channel-level importance scores rather than token-level scores, allowing for finer-grained semantic information preservation during fusion.
  4. Token Interaction: A cross-attention mechanism is used to integrate information between the original high-resolution tokens and the downsampled cluster tokens, ensuring effective information flow and retaining fine-grained details.

Datasets

FTCFormer was evaluated on a comprehensive set of 32 image classification datasets across diverse domains:

  • Natural Images: ImageNet-1k, Tiny ImageNet, STL10, ImageNette, Caltech101, Caltech256.
  • Fine-Grained: Flowers102, Food101, Stanford Cars, Oxford-IIIT Pet, Aircraft.
  • Medical Images: Blood Cell, PCAM, SD-198.
  • Remote Sensing: WHU-RS19, RESISC45, EuroSAT, UC Merced.
  • MNIST-like: MNIST, FMNIST, SVHN, QMNIST, EMNISTletter, EMNISTbyclass, KMNIST.
  • CIFAR-like: CIFAR-10, CIFAR-100, GTSRB, CINIC-10.
  • Other Domains: DTD, ImageNet-Sketch, FER2013.

No new benchmarks were introduced; the focus was on evaluating performance across existing diverse datasets.

Key Insights and Ideas

  • Semantic Tokenization is Key: The paper strongly reinforces the idea that moving beyond fixed, grid-based tokenization to semantically driven token generation is crucial for improving ViT performance and efficiency.
  • Fuzzy Logic for Robustness: Incorporating fuzzy logic (FKNN) into clustering significantly enhances robustness against common issues like hyperparameter sensitivity and noisy or uneven data distributions, which plagued previous clustering-based methods.
  • Connectivity Matters for Assignment: Relying solely on distance for token assignment is insufficient. The SCS metric, by considering shared neighbors and local density, provides a more intelligent way to group tokens, especially in complex feature spaces.
  • Channel-Level Merging Preserves Detail: Merging tokens at the channel level (Cmerge) is more effective than token-level merging because it retains finer-grained semantic distinctions within features, leading to richer representations.
  • Generalizability Across Domains: The FTCM module demonstrates remarkable adaptability and effectiveness across a wide array of visual domains, from natural images to medical scans and remote sensing data.

Key Results

  • Consistent Improvement: FTCFormer consistently outperforms its baseline, TCFormer, across all 32 datasets.
  • Significant Gains: Average accuracy improvements include:
  • 1.43% on fine-grained datasets.
  • 1.09% on natural image datasets.
  • 0.97% on medical image datasets.
  • 0.55% on remote sensing datasets.
  • Component Contributions: Ablation studies show that DPC-FKNN provides the most substantial improvement (up to 2.89%), followed by SCS (up to 0.61%) and Cmerge.
  • Computational Efficiency: The FTCM module introduces only marginal overhead in terms of GFLOPs (+0.26) and parameters (+0.38M), offering a favorable trade-off between performance and computational cost.
  • Qualitative Visualization: Visualizations show that FTCFormer allocates more and finer tokens to semantically important regions (faces, digits, lesions) and fewer, coarser tokens to less informative areas (background), aligning with its design objective.

Limitations and Future Work

  • Hyperparameter Sensitivity (Reduced but Present): While DPC-FKNN and SCS reduce hyperparameter sensitivity compared to previous methods, optimal performance still occurs around specific values (e.g., KFuzzy=5, Kscs=5), suggesting some residual sensitivity.
  • Near-Saturation Performance: On datasets where performance is already very high (e.g., >99% accuracy), FTCFormer shows only marginal improvements, indicating it performs well even in near-saturation scenarios.
  • Future Work: The authors suggest exploring strategies to accelerate training on high-resolution images and extending the clustering principles of FTCFormer to convolutional neural networks.

Summary updated

Abstract

Transformer-based deep neural networks have achieved remarkable success across various computer vision tasks, largely attributed to their long-range self-attention mechanism and scalability. However, most transformer architectures embed images into uniform, grid-based vision tokens, neglecting the underlying semantic meanings of image regions, resulting in suboptimal feature representations. To address this issue, we propose Fuzzy Token Clustering Transformer (FTCFormer), which incorporates a novel clustering-based downsampling module to dynamically generate vision tokens based on the semantic meanings instead of spatial positions. It allocates fewer tokens to less informative regions and more to represent semantically important regions, regardless of their spatial adjacency or shape irregularity. To further enhance feature extraction and representation, we propose a Density Peak Clustering-Fuzzy K-Nearest Neighbor (DPC-FKNN) mechanism for clustering center determination, a Spatial Connectivity Score (SCS) for token assignment, and a channel-wise merging (Cmerge) strategy for token merging. Extensive experiments on 32 datasets across diverse domains validate the effectiveness of FTCFormer on image classification, showing consistent improvements over the TCFormer baseline, achieving gains of improving 1.43% on five fine-grained datasets, 1.09% on six natural image datasets, 0.97% on three medical datasets and 0.55% on four remote sensing datasets. The code is available at: https://github.com/BaoBao0926/FTCFormer/tree/main.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Stanford CarsFTCFormerclassification accuracy84.55+2.72 vs baselineresolution=224×224
Source quote
L195: FTCFormer │ 79.12 │ FTCFormer │ 84.55
RESISC45FTCFormerclassification accuracy96.62+0.19 vs baselineresolution=224×224
Source quote
L212: FTCFormer │ 96.62
PCamFTCFormerclassification accuracy87.49+1.02 vs baselineresolution=64×64
Source quote
L229: FTCFormer │ 87.49
Reported baseline / comparator measurements (3)
BenchmarkMethodMetricScoreProtocol / Evidence
Stanford CarsTCFormer baselineclassification accuracy81.83resolution=224×224
Source quote
L194: TCFormer \cite{tcformer} │ 77.83 │ TCFormer \cite{tcformer} │ 81.83
RESISC45TCFormer baselineclassification accuracy96.43resolution=224×224
Source quote
L211: TCFormer \cite{tcformer} │ 96.43
PCamTCFormer baselineclassification accuracy86.47resolution=64×64
Source quote
L228: TCFormer \cite{tcformer} │ 86.47
BibTeX
@misc{bao2025ftcformer,
  author = {Muyi Bao and Changyu Zeng and Yifan Wang and Zhengni Yang and Zimu Wang and Guangliang Cheng and Jun Qi and Wei Wang},
  title = {{FTCFormer: Fuzzy Token Clustering Transformer for Image Classification}},
  year = {2025},
  eprint = {2507.10283},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.10283},
}
Figure