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, human can learn new classes quickly even given few samples since human can tell what discriminative features should be focused on about each category based on both the visual and semantic prior knowledge. To better utilize those prior knowledge, we propose the SEmantic Guided Attention (SEGA) mechanism where the semantic knowledge is used to guide the visual perception in a top-down manner about what visual features should be paid attention to when distinguishing a category from the 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 anticipated function and outperforms state-of-the-art results.

Introduction

Few-shot learning (FSL) aims to recognize novel categories from a limited number of examples. The primary obstacle is data scarcity; a model might incorrectly associate irrelevant background features with a new class due to the lack of diverse samples. Humans mitigate this by using prior knowledge. For instance, knowing a "fennec fox" has "unusually large ears" allows a person to focus on that specific trait even when seeing the animal for the first time. SEGA bridges this gap by using high-level semantic guidance to filter visual features and focus on what truly matters for classification.

Methodology

The SEGA framework consists of three primary components designed to refine visual representations through semantic filtering.

The SEGA architecture: Semantic embeddings are mapped to attention vectors that refine visual prototypes through element-wise multiplication.
  1. Feature Extractor: A ResNet-12 backbone is pre-trained on base classes to establish a robust visual feature space.
  2. Visual Prototype Construction: For a novel category, a prototype is formed by averaging the features of available samples. Visual priors from base classes are transferred via an attention mechanism to stabilize these prototypes.
  3. Semantic Guided Attention: This is the core innovation. The model takes a semantic embedding (e.g., a GloVe vector of the class name) and uses a Multi-Layer Perceptron (MLP) to map it to a visual attention vector. This vector acts as a feature selector, performing a Hadamard product with the visual prototype to emphasize discriminative dimensions and suppress noise.

Final classification is achieved using a Cosine Classifier, comparing query image features against these refined prototypes.

Results and Discussion

SEGA was evaluated on four standard benchmarks: miniImageNet, tieredImageNet, CIFAR-FS, and CUB. It achieved state-of-the-art performance, particularly in 1-shot scenarios. For example, on miniImageNet (1-shot), SEGA reached 69.04% accuracy, a significant improvement over previous semantic-based methods.

t-SNE visualizations of novel class prototypes (a) before semantic attention, (b) after semantic attention, and (c) after inversed semantic attention.

The impact of semantic guidance is clearly visible in t-SNE visualizations. Without attention, prototypes are scattered; applying SEGA "tightens" these clusters, making classes more separable. Conversely, applying "inversed" attention—focusing on the least important features—leads to significant overlap and performance degradation, confirming that the model correctly identifies discriminative traits.

Grad-CAM analysis further reveals that SEGA helps the model ignore background distractors and focus on the object of interest. Interestingly, the model also learns meaningful feature correlations; for instance, intersecting attention vectors for "dalmatian" and "ladybug" highlights "spots," demonstrating the semantic interpretability of the learned attention. Ablation studies further validated the approach: using random semantic labels performed worse than using no semantics at all, proving that the model relies on the actual semantic content of the labels.

Conclusion

SEGA demonstrates that top-down semantic guidance can significantly improve the discriminative power of visual prototypes in few-shot learning. While the benefits are most pronounced in data-scarce (1-shot) scenarios, the method provides a robust way to integrate multimodal prior knowledge. Future work may explore more sophisticated semantic sources, such as large-scale language models, to provide even more granular guidance.

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