HyperShot: Few-Shot Learning by Kernel HyperNetworks

Marcin Sendera, Marcin Przewiezlikowski, Konrad Karanowski, Maciej Zieba, Jacek Tabor, Przemyslaw Spurek

Abstract

HyperShot is a novel few-shot learning framework that integrates kernel methods with the hypernetwork paradigm. By mapping the relational structure of support data to classifier weights, it avoids slow gradient-based adaptation. Experiments on CUB, mini-ImageNet, and cross-domain benchmarks demonstrate its robustness and competitive performance, particularly in challenging cross-domain adaptation tasks.

Introduction

Few-shot learning (FSL) aims to recognize new categories from a limited number of examples. Existing approaches typically fall into two categories: metric-based methods, which rely on fixed distance metrics between query images and class prototypes, and optimization-based methods, which adapt models via gradient descent. However, metric methods can be overly rigid, while optimization methods are often computationally intensive and hyperparameter-sensitive.

HyperShot addresses these limitations by focusing on the relations between classes within a task. By utilizing kernels to capture these relations, the model can adapt to new domains more effectively than methods relying solely on absolute feature values.

The HyperShot Framework

The core innovation of HyperShot is the Kernel HyperNetwork, which operates in three distinct stages to generate task-specific classifier weights without extensive optimization.

Overview of the HyperShot architecture, illustrating the flow from support images to kernel matrix generation and hypernetwork-based weight prediction.
  1. Embedding & Kernelization: Support images ($X_S$) are processed through a backbone encoder ($E$). A kernel matrix ($K_{S,S}$) is then computed, representing the pairwise similarities between all support examples. This captures the structural "geometry" of the task.
  2. Hypernetwork Weight Generation: The kernel matrix is fed into a Hypernetwork ($H$). Because the input is relational, the Hypernetwork learns to produce parameters ($\theta_T$) for a target classification module based on how classes relate to one another.
  3. Classification: For a query image ($x_q$), the model calculates kernel values ($k_{q,S}$) against the support set. These values are processed by the target module ($T$) using the generated weights ($\theta_T$) to produce the final class probability $p(y|x_q, S)$.

An optional "adaptation" variant allows for a few gradient steps on the hypernetwork's output to further refine weights for specific tasks.

Experimental Evaluation

HyperShot was evaluated on standard FSL benchmarks including CUB (fine-grained birds) and mini-ImageNet (general objects). Crucially, the authors tested cross-domain adaptation, such as training on mini-ImageNet and testing on CUB, or training on Omniglot and testing on EMNIST.

Key Results

HyperShot demonstrates competitive performance on standard benchmarks and exceptional performance in cross-domain settings. On CUB 1-shot, it achieved 66.13% accuracy, significantly outperforming baseline metric methods like ProtoNet (52.52%).

Cross-domain classification results comparing HyperShot against state-of-the-art methods.

As shown in the table above, HyperShot's strength is most apparent in cross-domain tasks. In the Omniglot $\rightarrow$ EMNIST 1-shot task, HyperShot reached 80.65% accuracy, a substantial improvement over MAML (72.68%) and RelationNet (75.62%). This suggests that focusing on relational structures via kernels provides a more domain-invariant representation than raw feature matching.

Insights and Ablations

  • Relational Robustness: By prioritizing the task structure (e.g., relative similarities) over specific feature magnitudes, HyperShot maintains high accuracy even when the visual domain changes significantly.
  • Architecture Optimization: Ablation studies indicated that a hypernetwork hidden size of 2048 to 4096 provides the optimal capacity for weight generation.
  • N-Shot Strategy: For 5-shot scenarios, averaging embeddings to create class-level prototypes before kernelization proved more stable than fine-grained image-level processing.

Conclusion and Future Work

HyperShot successfully bridges kernel methods and hypernetworks to provide a fast, adaptive framework for few-shot learning. While it requires significant training time to converge (up to 10,000 epochs), its ability to generalize across domains without heavy fine-tuning is a major advantage. Future research will explore pre-training strategies to reduce training overhead and investigate more complex target network architectures.

Summary updated

BibTeX
@inproceedings{sendera2023hypershot,
  author = {Marcin Sendera and Marcin Przewiezlikowski and Konrad Karanowski and Maciej Zieba and Jacek Tabor and Przemyslaw Spurek},
  title = {{HyperShot: Few-Shot Learning by Kernel HyperNetworks}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2023},
  doi = {10.1109/wacv56688.2023.00250},
}
Figure