Abstract
Few-shot learning (FSL) aims to recognize novel categories from limited labeled data. Traditional two-stage paradigms—pre-training followed by episodic meta-training—often suffer from overfitting to base classes due to a reliance on cross-entropy loss. This paper proposes a novel framework that integrates contrastive learning into both stages. By employing global and local contrastive losses and a "cross-view episodic training" mechanism, the model learns more transferable representations. Experimental results on miniImageNet, tieredImageNet, and CIFAR-FS demonstrate state-of-the-art performance.
Introduction
Few-shot learning (FSL) is a challenging task where models must learn to recognize new classes using only a handful of labeled examples. The standard approach typically involves a two-stage process: pre-training a feature extractor on a large base dataset, followed by meta-training using episodes to simulate the few-shot setting. However, a significant bottleneck exists: both stages often rely on standard cross-entropy (CE) loss. While CE is effective for classification, it tends to make models overfit to specific features of base classes, discarding information that might be vital for identifying unseen novel classes. This paper addresses the challenge of learning representations that are not only discriminative for training data but also highly transferable to entirely new categories.
Methodology
The proposed framework seamlessly integrates contrastive learning into the FSL pipeline across two distinct stages: pre-training and meta-training.
Pre-training Stage
In the pre-training stage, the authors augment standard classification with three contrastive components:
- Global Self-Supervised Loss: A standard InfoNCE loss ensuring different augmentations of the same image have similar global feature vectors.
- Local Self-Supervised Loss: A key novelty involving Map-Map and Vector-Map modules. Map-Map aligns local feature maps between two views of an image, while Vector-Map relates a global feature vector to local feature maps. This forces the model to capture fine-grained, local discriminative information.
- Global Supervised Contrastive Loss: This uses class labels to pull features of different images from the same category closer together in the embedding space.
Meta-training Stage
The meta-training stage introduces a rethink of episodic training:
- Cross-view Episodic Training (CVET): Instead of training on a single version of an episode, the model processes two different augmented views of the same episode. It must perform nearest-centroid classification across these views (e.g., classifying a query from View 1 using the support set from View 2), forcing the model to overcome view bias.
- Distance-scaled Contrastive Loss: Supervised contrastive learning is adapted to the episodic setting with a distance coefficient ($\lambda$) that accounts for similarity between instances, providing a more nuanced contrastive signal.
Key Insights and Visual Analysis
A central finding of this work is that local information is crucial. While most contrastive FSL methods focus on global vectors, the Map-Map and Vector-Map modules preserve spatial relationships, helping the model generalize to novel objects where global shapes might differ but local textures remain similar.
Furthermore, the model achieves better consistency across tasks. CVET treats an entire few-shot task as a context, learning meta-knowledge that is robust to augmentation noise. The impact of these contrastive losses is clearly visible in feature space visualizations.
As shown in the t-SNE plots, while cross-entropy creates tight clusters for base classes, it often leaves novel classes poorly separated. The addition of contrastive losses results in significantly cleaner and more separable clusters for classes the model has never seen before, directly addressing the "CE bias."
Experimental Results
The method was evaluated on standard benchmarks including miniImageNet, tieredImageNet, and CIFAR-FS. It consistently outperformed the baseline (FEAT) and achieved competitive or superior results compared to other state-of-the-art (SOTA) methods.
- miniImageNet: Achieved 70.19% (1-shot) and 84.66% (5-shot) accuracy.
- tieredImageNet: Reached 72.62% (1-shot) and 86.62% (5-shot).
- CIFAR-FS: Surpassed SOTA by 0.46% in 1-shot and 0.19% in 5-shot tasks.
Ablation studies confirmed that both the local contrastive losses in pre-training and the CVET mechanism in meta-training are significant contributors to the final performance.
Conclusion
This paper demonstrates that integrating contrastive learning into both pre-training and meta-training stages significantly enhances the generalizability of few-shot learning models. By focusing on local features and cross-view consistency, the proposed framework overcomes the limitations of traditional cross-entropy-based training. Future work may explore more sophisticated augmentation strategies or application to non-metric-based FSL architectures.
Summary updated