Large-Margin kNN Classification Using a Deep Encoder Network

Martin Renqiang Min, David A. Stanley, Zineng Yuan, Anthony J. Bonner, Zhaolei ZhangarXiv 2009

Abstract

This paper presents DNet-kNN, a framework designed to improve k-Nearest Neighbors (kNN) classification by learning non-linear distance metrics through deep neural networks. By combining generative pretraining using Restricted Boltzmann Machines (RBMs) with a large-margin discriminative objective, the authors demonstrate a method for mapping high-dimensional data into low-dimensional spaces that preserve class separability. Experimental results on digit recognition benchmarks show that DNet-kNN outperforms standard kNN, support vector machines, and unsupervised deep autoencoders.

Introduction

The performance of the k-Nearest Neighbors (kNN) algorithm is fundamentally tied to the choice of distance metric. In high-dimensional datasets, simple Euclidean distance often fails because it cannot distinguish between class-relevant features and noise. While Large Margin Nearest Neighbor (LMNN) techniques have been developed to learn better metrics, they are traditionally limited to linear transformations. Such models often lack the capacity to capture the complex, non-linear manifolds characteristic of real-world data like images.

DNet-kNN addresses this limitation by using a deep encoder network to learn a scalable, non-linear mapping. This approach allows for effective dimensionality reduction while optimizing for a large-margin classification objective.

Methodology

The DNet-kNN framework utilizes a deep encoder network, typically comprising four hidden layers. The training process involves two primary phases:

1. Generative Pretraining

The network is initialized using stacked Restricted Boltzmann Machines (RBMs). This greedy, layer-wise pretraining (illustrated in Figure 1) provides a sensible starting point for the weights, helping the model avoid the vanishing gradient problems associated with deep architectures.

The architecture shows the transition from RBM pretraining (a) to a deep autoencoder (b), which serves as the foundation for the discriminative model.

2. Discriminative Fine-Tuning

Unlike standard autoencoders that focus on input reconstruction, DNet-kNN is fine-tuned to minimize a large-margin objective function. This objective is designed to keep "target neighbors" (points of the same class) close together while pushing "impostors" (points of different classes) outside of a defined safety margin. To maintain computational efficiency on large datasets, the authors employ a "triples matrix" to track these relationships and use conjugate-gradient updates for optimization.

Experimental Results

The authors evaluated DNet-kNN on the USPS and MNIST handwritten digit benchmarks.

Performance on MNIST

DNet-kNN achieved a test error of 0.94% on the MNIST dataset, significantly outperforming Deep Belief Networks (1.25%), SVMs (1.4%), and standard kNN (3.05%).

Robustness to Dimensionality Reduction

A key advantage of DNet-kNN is its performance in low-dimensional "code" spaces. On the USPS dataset, the model maintained low error rates even when compressing data to as few as 2 or 5 dimensions—scenarios where standard unsupervised deep autoencoders (DA) failed to maintain classification accuracy.

Comparison of test error on the USPS dataset. DNet-kNN (blue) consistently maintains lower error than the deep autoencoder (red) across various dimensionalities.

Key Insights

  • Discriminative vs. Generative: While generative pretraining is crucial for initialization, the final discriminative fine-tuning allows the model to focus entirely on class separation rather than reconstruction.
  • Efficiency of Pretraining: The authors found that RBM pretraining allowed the discriminative learning process to converge much faster, often requiring only 3-5 epochs to reach a superior local minimum.

Discussion and Limitations

DNet-kNN provides a powerful tool for supervised dimensionality reduction and non-linear metric learning. However, the 2009 implementation faced certain constraints, such as the use of fixed neighbors identified in the original pixel space. The authors suggest that a "dynamic" version, where neighbors are re-calculated in the learned feature space during training, could further enhance performance. Additionally, incorporating within-class constraints from methods like Stochastic Neighbor Embedding (SNE) could lead to even more refined clustering.

Summary updated

BibTeX
@misc{min2009large,
  author = {Martin Renqiang Min and David A. Stanley and Zineng Yuan and Anthony J. Bonner and Zhaolei Zhang},
  title = {{Large-Margin kNN Classification Using a Deep Encoder Network}},
  year = {2009},
  eprint = {0906.1814},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/0906.1814},
}
Figure