Skip to main content
QUICK REVIEW

[Paper Review] SpatialFormer: Semantic and Target Aware Attentions for Few-Shot Learning

Jinxiang Lai, Siqian Yang|arXiv (Cornell University)|Mar 15, 2023
Domain Adaptation and Few-Shot LearningComputer Science3 citations
TL;DR

This paper proposes SpatialFormer, a novel Transformer-based architecture for few-shot learning that leverages semantic-level similarity between support and query features to generate more accurate attention maps. By introducing SpatialFormer Semantic Attention (SFSA) and SpatialFormer Target Attention (SFTA), the method enhances discriminative feature learning by highlighting semantically aligned regions and foreground object areas while reducing background distraction, achieving new state-of-the-art performance on miniImageNet and tieredImageNet benchmarks.

ABSTRACT

Recent Few-Shot Learning (FSL) methods put emphasis on generating a discriminative embedding features to precisely measure the similarity between support and query sets. Current CNN-based cross-attention approaches generate discriminative representations via enhancing the mutually semantic similar regions of support and query pairs. However, it suffers from two problems: CNN structure produces inaccurate attention map based on local features, and mutually similar backgrounds cause distraction. To alleviate these problems, we design a novel SpatialFormer structure to generate more accurate attention regions based on global features. Different from the traditional Transformer modeling intrinsic instance-level similarity which causes accuracy degradation in FSL, our SpatialFormer explores the semantic-level similarity between pair inputs to boost the performance. Then we derive two specific attention modules, named SpatialFormer Semantic Attention (SFSA) and SpatialFormer Target Attention (SFTA), to enhance the target object regions while reduce the background distraction. Particularly, SFSA highlights the regions with same semantic information between pair features, and SFTA finds potential foreground object regions of novel feature that are similar to base categories. Extensive experiments show that our methods are effective and achieve new state-of-the-art results on few-shot classification benchmarks.

Motivation & Objective

  • To address inaccuracies in CNN-based cross-attention due to local feature modeling in few-shot learning.
  • To mitigate background distraction caused by semantically similar but irrelevant regions in support-query pairs.
  • To overcome the limitation of standard Transformers, which assume instance-level similarity rather than semantic-level similarity in few-shot settings.
  • To design a new attention mechanism that operates on global, semantic-level feature correspondence for improved few-shot classification.
  • To integrate target-aware and task-aware modules that enhance foreground representation and inter-class separability.

Proposed method

  • Proposes SpatialFormer, a novel Transformer variant that models spatial-wise cross-attention based on semantic-level similarity rather than instance-level similarity.
  • Introduces SpatialFormer Semantic Attention (SFSA), which highlights regions with shared semantic content between support and query features.
  • Introduces SpatialFormer Target Attention (SFTA), which uses class weights from base categories as reference to emphasize potential foreground object regions in novel features.
  • Employs a multi-task learning framework with a rotation prediction head to improve feature representation quality.
  • Integrates a Novel Task Attention (NTA) module that uses task-specific classifier weights to increase inter-class feature distance.
  • Combines SFSA and SFTA into a unified STA module to generate discriminative, target-focused features for metric learning.

Experimental results

Research questions

  • RQ1Can a Transformer-based attention mechanism designed for semantic-level similarity improve few-shot classification beyond instance-level similarity assumptions?
  • RQ2Can class weights from base categories be effectively used as a target-aware reference to enhance foreground region attention in novel classes?
  • RQ3Does incorporating a task-aware attention module that increases inter-class feature distance lead to better generalization in few-shot learning?
  • RQ4Can global feature modeling via SpatialFormer reduce inaccuracies in attention maps caused by local CNN-based attention?
  • RQ5To what extent do the proposed modules improve performance on standard few-shot benchmarks like miniImageNet and tieredImageNet?

Key findings

  • SpatialFormer achieves consistent improvements over standard Transformers on 1/5-shot tasks across miniImageNet and tieredImageNet, with a 0.45% to 0.55% accuracy gain on 1-shot and 5-shot settings.
  • Using class weights $W_G$ as a reference in SFTA leads to a 0.15% to 0.35% performance boost compared to using query features alone.
  • The NTA module improves accuracy by 0.36% to 0.82% on 1-shot tasks and up to 1.10% on 10-shot tasks, with larger gains as shot count increases.
  • The multi-task loss with rotation classifier and optimal λ=1.0 yields the best performance, improving 1-shot accuracy by 1.45% over single-task training.
  • Visualizations show that STANet produces sharper, more focused class activation maps centered on target objects, unlike CAN, which suffers from background attention.
  • STANet achieves new state-of-the-art results, with 69.86% on 1-shot and 85.16% on 5-shot accuracy on WRN-28 backbone for miniImageNet.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.