LGM-Net: Learning to Generate Matching Networks for Few-Shot Learning

Huai-Yu Li, Weiming Dong, Xing Mei, Chongyang Ma, Feiyue Huang, Bao-Gang Hu

Abstract

Few-shot learning (FSL) remains a significant challenge in computer vision, requiring models to generalize from a handful of labeled examples. While existing meta-learning approaches rely on iterative optimization or fixed metric spaces, LGM-Net introduces a novel paradigm: directly generating neural network weights for specific tasks. By utilizing a "MetaNet" to map support sets to functional parameters for a "TargetNet," LGM-Net achieves state-of-the-art performance on benchmarks like miniImageNet without the need for test-time fine-tuning.

Introduction

Standard deep learning models are notoriously data-hungry, often requiring thousands of labeled examples to achieve high accuracy. In contrast, humans can learn new concepts from a single glance. Few-shot learning (FSL) aims to bridge this gap. Current meta-learning strategies typically fall into two categories: optimization-based methods (like MAML), which seek a versatile initialization for rapid adaptation, and metric-based methods (like Matching Networks), which learn to compare new inputs against a support set in a learned embedding space.

However, optimization-based methods are computationally expensive at test time due to required gradient updates, while metric-based methods are often limited by the rigidity of their comparison logic. LGM-Net (Learning to Generate Matching Networks) proposes a hybrid approach: it uses the architecture of a Matching Network but generates its weights dynamically based on the task at hand, enabling "zero-step" adaptation.

Architecture and Methodology

The LGM-Net framework consists of two primary components: the TargetNet and the MetaNet.

The LGM-Net architecture, illustrating how the MetaNet generates weights for the TargetNet based on support set samples.

The TargetNet (The Worker)

The TargetNet is a neural network designed for classification. Unlike standard networks, its weights ($\theta_i$) are not learned through backpropagation on a specific task. Instead, they are placeholders that receive values generated by the MetaNet.

The MetaNet (The Manager)

The MetaNet observes the support set ($S_i^{train}$) and produces the weights for the TargetNet. It includes several key innovations:

  1. Task Context Encoder ($g_{\phi_e}$): This module computes the mean and variance of features from the support set to create a task representation. This statistical approach is order-invariant and more efficient than recurrent architectures like LSTMs.
  2. Conditional Weight Generator ($g_{\phi_w}$): This sub-network takes the task representation and outputs the specific convolutional and fully connected weights for the TargetNet.
  3. Intertask Normalization (ITN): To leverage shared information across different tasks, the authors apply Batch Normalization across a batch of diverse tasks during training.
  4. Weight Normalization (WN): A modified L2 normalization is applied to the generated parameters to ensure numerical stability and prevent weight explosion.

Experimental Evaluation

The model was evaluated across diverse domains, ranging from simple 2D synthetic data to complex natural images.

Visualization of the four synthetic 2D datasets used to evaluate LGM-Net's ability to form complex decision boundaries.

Datasets

  • Synthetic 2D Datasets: Four custom datasets—Blobs, Lines, Spirals, and Circles—were used to visualize how the model constructs decision boundaries from minimal data points.
  • Omniglot: A dataset of 1,623 handwritten characters from 50 different alphabets, often used as a baseline for FSL.
  • miniImageNet: A challenging subset of ImageNet containing 100 classes, providing a rigorous test for natural image classification.

Key Results and Insights

LGM-Net demonstrated superior performance and efficiency compared to existing baselines:

  • State-of-the-Art Accuracy: On the miniImageNet 5-way 1-shot task, LGM-Net achieved 69.13% accuracy, significantly outperforming MAML (~48%) and LEO (~61%).
  • Efficiency: Because the MetaNet generates weights in a single forward pass, LGM-Net requires no iterative fine-tuning at test time. This makes it orders of magnitude faster than optimization-based methods during inference.
  • Qualitative Success: On the "Circles" synthetic dataset, LGM-Net successfully generated weights that formed a perfect circular boundary with only three support points, demonstrating its ability to apply learned priors to new geometric tasks.

Conclusion and Future Work

LGM-Net proves that neural network weights can be treated as a direct mapping from a data distribution. By bypassing the need for test-time optimization, it offers a fast and accurate solution for few-shot scenarios. Future research may focus on enhancing the Task Context Encoder to better capture information in 5-shot or 10-shot scenarios and exploring explainable AI (XAI) techniques to interpret the generated weight spaces.

Summary updated

BibTeX
@inproceedings{li2019lgm,
  author = {Huai-Yu Li and Weiming Dong and Xing Mei and Chongyang Ma and Feiyue Huang and Bao-Gang Hu},
  title = {{LGM-Net: Learning to Generate Matching Networks for Few-Shot Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2019},
  url = {https://openreview.net/forum?id=Bk49Ohb_Wr},
}
Figure