A Multilayer Framework for Online Metric Learning

Wenbin Li, Yanfang Liu, Jing Huo, Yinghuan Shi, Yang Gao, Lei Wang, Jiebo Luo

TL;DR

This paper introduces Multi-Layer Online Metric Learning (MLOML), a novel deep framework that stacks online metric learning algorithms with nonlinear activation functions to progressively refine distance metrics for streaming data. By incorporating a newly designed Mahalanobis-based Online Metric Learning (MOML) base layer, the framework can capture complex, nonlinear data distributions on the fly with strong theoretical guarantees.

What Problem Does This Paper Address?

Distance metric learning aims to find a data transformation where similar items are pulled closer together and dissimilar items are pushed apart. In many real-world applications (like credit analysis or ad click prediction), data arrives continuously as a stream, requiring online metric learning (OML) algorithms that can update efficiently without retraining from scratch.

However, existing OML algorithms suffer from a major limitation: they only learn a single linear metric space. When data distributions are highly complex and nonlinearly distributed, these linear methods fall short. While deep metric learning handles nonlinearity well, it typically relies on batch training and heavy backpropagation, making it unsuitable for true streaming environments. This paper bridges the gap by introducing a multi-layer, nonlinear framework designed specifically for online streaming data.

Methods

The authors propose the Multi-Layer Online Metric Learning (MLOML) framework. Instead of learning a single metric space, MLOML stacks multiple metric-learning algorithms sequentially, separated by standard nonlinear activation layers (such as ReLU, Sigmoid, or tanh).

Fig. 2. Framework of the proposed multi-layer online metric learning (MLOML), where each metric layer Mn is an online metric learning algorithm. Here we take three metric layers and two ReLU layers as an example, i.e., n = 3.

1. The Base Layer: MOML

To power this framework efficiently, the authors developed a new base algorithm called Mahalanobis-based Online Metric Learning (MOML). MOML utilizes:

  • One-pass triplet construction: It constructs triplets $\langle x, x^+, x^-\rangle$ (anchor, positive, negative) on the fly from streaming data, avoiding the need to know all constraints in advance.
  • Passive-Aggressive optimization: It features a convex objective function with a closed-form solution at each step, ensuring low computational complexity ($O(d^2)$).

2. Training Strategies

A unique aspect of MLOML is how it can be trained. The authors explore three propagation strategies:

  • Forward Propagation (MLOML-FP): Parameters of each metric layer are updated immediately using its own local loss during the forward pass. This allows the network to explore new feature spaces sequentially without waiting for backpropagation.
  • Backward Propagation (MLOML-BP): The entire network is trained globally using only the final loss layer via stochastic gradient descent (SGD).
  • Forward-Backward Propagation (MLOML-FBP): Combines both, using FP for rapid local updates and BP to fine-tune the entire network.

Datasets

The framework was evaluated on 12 benchmark datasets from the UCI Machine Learning Repository, representing a wide variety of scales and feature dimensions:

  • Small/Medium scale: lsvt, iris, wine, spect, ionosphere, balance, breast, pima, diabetic.
  • Large scale / High dimensional: pems, waveform, mlprove.

All datasets were normalized using $\ell_2$ normalization, and high-dimensional datasets ($\ge 200$ features) were reduced to 100 dimensions using PCA prior to training.

Key Insights and Ideas

  • Progressive Refinement: As data passes through successive layers, the metric space becomes increasingly discriminative. The intra-class distance shrinks, and the inter-class distance expands, making complex distributions linearly separable by the final layer.

    Fig. 1. An illustration of online hierarchical metric learning by learning new metric spaces progressively.
  • The Power of Forward-Only Training: Surprisingly, training the network using only Forward Propagation (MLOML-FP) performs exceptionally well and is computationally the fastest ($O(nd^2)$ where $n$ is the number of layers). Because each layer is a self-contained convex OML algorithm, it doesn't suffer from the vanishing gradient problems common to pure backpropagation in deep networks.

  • Theoretical Guarantees: The authors prove a tight regret bound for the MOML base layer. Crucially, they provide a theoretical guarantee showing that subsequent layers in the MLOML-FP framework will always learn a feature space that is at least as good as (or more discriminative than) the preceding layers.

Key Results

  • Superior Accuracy: MLOML (specifically MLOML-r using ReLU) consistently outperformed state-of-the-art single-layer OML algorithms (like OASIS, LEGO, and OPML) across the majority of the 12 UCI datasets.
  • Visualizing the Transformation: Using PCA to project the learned spaces into 2D, the authors demonstrated how chaotic original feature spaces are beautifully untangled layer-by-layer.
Feature visualization across layers for four UCI datasets
  • Efficiency: MOML achieves a significantly lower running time than comparable online methods like OPML while maintaining superior or competitive error rates.

Limitations and Future Work

  • High-Dimensional Scaling: Currently, MOML learns a full Mahalanobis matrix $M \in \mathbb{R}^{d \times d}$. For extremely high-dimensional data, this becomes computationally expensive. The authors suggest that future iterations could employ diagonal matrices or online feature selection to mitigate this.
  • Hyperparameter Tuning for Depth: The optimal number of layers varies depending on the complexity of the task. In this paper, the depth was uniformly specified (typically 3 or 5 layers). Automatically determining the ideal number of layers for a given dataset remains an open research question.

Summary updated

BibTeX
@article{li2023multilayer,
  author = {Wenbin Li and Yanfang Liu and Jing Huo and Yinghuan Shi and Yang Gao and Lei Wang and Jiebo Luo},
  title = {{A Multilayer Framework for Online Metric Learning}},
  journal = {IEEE Trans. Neural Networks Learn. Syst.},
  year = {2023},
  doi = {10.1109/tnnls.2022.3213511},
}
Figure