Model-Agnostic Graph Regularization for Few-Shot Learning

Ethan Shen, Maria Brbic, Nicholas Monath, Jiaqi Zhai, Manzil Zaheer, Jure Leskovec

Few-shot learning (FSL) aims to train models that can recognize new categories from just one or five examples—a task humans excel at by leveraging prior knowledge, but machines find incredibly difficult. While meta-learning and fine-tuning have made strides, they often ignore the rich semantic relationships between classes (e.g., a "Husky" is more similar to a "Wolf" than to a "Toaster").

Existing attempts to incorporate this "side information" via Knowledge Graphs (KGs) usually involve highly complex, specialized architectures like Graph Neural Networks (GNNs) that are hard to tune and incompatible with different FSL frameworks. This paper introduces a simple, "plug-and-play" graph regularization term that allows any few-shot learning model to leverage external knowledge (like WordNet).

A Simple, Model-Agnostic Approach

The core contribution is a graph regularization objective ($L_{graph}$) that can be added to any standard classification loss. The authors use a random walk-based approach (inspired by node2vec) to define a loss that ensures class-level representations—such as prototypes or classifier weights—preserve the neighborhood similarities found in a knowledge graph. If two classes are close in the graph, their learned parameters are penalized if they are far apart in the embedding space.

This approach is uniquely model-agnostic. It can be integrated into:

  • Metric-Based models (e.g., Prototypical Networks): By regularizing the class prototypes.
  • Optimization-Based models (e.g., LEO): By regularizing the latent class encodings.
  • Fine-Tuning models (e.g., S2M2R): By regularizing the weights of the final classification layer during adaptation.

Visualizing the "Safety Net"

Graph regularization acts as a powerful structural prior. When a model only has one image of a "Tibetan Terrier," it might overfit to irrelevant features like the background. The graph prior "reminds" the model that this class should look similar to other "Terriers," preventing the learned parameters from wandering too far astray.

Comparison of decision boundaries without (left) and with (right) graph regularization. The graph prior helps the model ignore outliers and better align prototypes with semantic clusters.

As shown in the visualization above, without the graph prior, decision boundaries can be heavily skewed by unrepresentative support points. With regularization, the boundaries become more robust and better reflect the underlying data distribution.

Performance and Robustness

The authors evaluated their method on standard benchmarks like Mini-ImageNet and the large-scale ImageNet-FS. On Mini-ImageNet, adding graph regularization to the S2M2R model improved 1-shot accuracy by ~2%. On the more challenging ImageNet-FS, it boosted the SGM baseline by a massive 6.7% in the 1-shot setting.

Classification loss as a function of shots (left) and task hardness (right). Graph regularization significantly reduces loss in low-shot regimes and maintains performance even as task difficulty increases.

Key experimental insights include:

  • Harder Tasks Benefit More: Synthetic experiments demonstrate that graph regularization provides the biggest boosts when support examples are uninformative or when the number of shots is extremely low. As seen in the figure above, the loss for the regularized model remains relatively stable even as task "hardness" increases.
  • Complexity vs. Structure: This simple regularization out-performed much more complex models like KGTN, suggesting that the structure of the knowledge is more important than the mechanism used to inject it.
  • Diminishing Returns: The performance gains are significantly higher for 1-shot tasks than for 5-shot tasks. As more labeled data becomes available, the data-driven signal eventually outweighs the knowledge-driven prior.

Conclusion

By introducing a simple penalty term rather than complex architectural changes, this method provides a scalable way to inject human-like semantic priors into machine learning models. While it depends on the availability of high-quality graphs, its consistent performance across different backbones (ResNet-18, WRN-28-10) and algorithms makes it a versatile tool for the few-shot learning toolbox.

Summary updated

BibTeX
@misc{shen2021model,
  author = {Ethan Shen and Maria Brbic and Nicholas Monath and Jiaqi Zhai and Manzil Zaheer and Jure Leskovec},
  title = {{Model-Agnostic Graph Regularization for Few-Shot Learning}},
  year = {2021},
  eprint = {2102.07077},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.07077},
}
Figure