SEGA: Semantic Guided Attention on Visual Prototype for Few-Shot Learning

Fengyuan Yang, Ruiping Wang, Xilin Chen

Abstract

Teaching machines to recognize a new category based on few training samples—especially only one—remains challenging owing to the incomprehensive understanding of the novel category caused by the lack of data. However, humans can learn new classes quickly even given few samples since humans can tell what discriminative features should be focused on about each category based on both visual and semantic prior knowledge. To better utilize this prior knowledge, we propose the SEmantic Guided Attention (SEGA) mechanism where semantic knowledge is used to guide visual perception in a top-down manner regarding what visual features should be paid attention to when distinguishing a category from others. As a result, the embedding of the novel class, even with few samples, can be more discriminative. Concretely, a feature extractor is trained to embed few images of each novel class into a visual prototype with the help of transferring visual prior knowledge from base classes. Then we learn a network that maps semantic knowledge to category-specific attention vectors which will be used to perform feature selection to enhance the visual prototypes. Extensive experiments on miniImageNet, tieredImageNet, CIFAR-FS, and CUB indicate that our semantic guided attention realizes the anticipated function and outperforms state-of-the-art results.

Introduction

Few-shot learning (FSL) aims to bridge the gap between machine and human learning by enabling models to recognize new categories from a handful of labeled examples. This is particularly relevant for "long-tail" distributions where data for rare categories is scarce. A primary challenge in 1-shot learning is that a model may overfit to non-essential features, such as a specific background or lighting condition, rather than the object itself.

Humans overcome this by leveraging semantic prior knowledge. For instance, if a person is told that a "fennec fox" is characterized by "unusually large ears," they can immediately identify the animal in a new image by focusing on that specific trait. SEGA mimics this top-down guidance by using semantic information—like class names—to filter and refine visual features.

Methodology

The SEGA framework operates through a three-stage process designed to integrate visual and semantic information effectively:

  1. Visual Prototype Generation: A standard backbone (e.g., ResNet-12) extracts features from the support set. These features are averaged to create a "visual prototype," benefiting from visual priors transferred from a large set of base classes.
  2. Semantic Mapping: The model processes word embeddings (such as pre-trained GloVe vectors) of class names through a multi-layer perceptron (MLP). This MLP transforms the semantic meaning into a category-specific attention vector.
  3. Feature Selection and Enhancement: The attention vector is applied to the visual prototype via a Hadamard product. This acts as a filter that amplifies dimensions relevant to the class (e.g., "spots" for a dalmatian) while suppressing noise.
The SEGA architecture: Semantic knowledge is mapped to attention vectors that refine visual prototypes through element-wise multiplication.

Classification is then performed using a Cosine Classifier, which calculates the similarity between a query image's features and these semantically enhanced prototypes.

Experimental Results

SEGA was evaluated on four standard benchmarks: miniImageNet, tieredImageNet, CIFAR-FS, and CUB. The model achieved state-of-the-art (SOTA) performance, particularly in 1-shot scenarios where data is most limited. On miniImageNet, SEGA reached 69.04% accuracy, a significant improvement over baselines lacking semantic guidance. On the fine-grained CUB dataset, it reached 84.57%, demonstrating its ability to distinguish between closely related species by focusing on subtle semantic attributes.

Qualitative Analysis and Visualizations

To verify that the model was truly utilizing semantic meaning, the researchers performed a "fake label" test. When incorrect semantic labels were provided, performance dropped sharply, confirming that the specific content of the word embeddings drives the accuracy gain.

Grad-CAM visualizations comparing SEGA against baselines. SEGA consistently focuses more accurately on the target object (e.g., the ferret or the crate) than models without semantic attention.

Visualizations using Grad-CAM (shown above) demonstrate that SEGA-enabled models focus more tightly on the actual object compared to "No Attention" baselines, which are often distracted by background textures. Furthermore, t-SNE plots revealed that semantic attention results in much tighter and more distinct class clusters, enhancing the model's robustness to noisy samples.

Conclusion

SEGA demonstrates that semantic knowledge can serve as a powerful top-down controller for visual feature selection in few-shot learning. While the benefit of this guidance is most pronounced in 1-shot scenarios, it provides a robust framework for integrating multimodal prior knowledge. Future work may involve utilizing more complex semantic sources, such as BERT embeddings or structured knowledge bases, to provide even more granular guidance for complex visual tasks.

Summary updated

BibTeX
@inproceedings{yang2022sega,
  author = {Fengyuan Yang and Ruiping Wang and Xilin Chen},
  title = {{SEGA: Semantic Guided Attention on Visual Prototype for Few-Shot Learning}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=ZtwQlRbjPE},
}
Figure