Skip to main content
QUICK REVIEW

[Paper Review] Neural Nearest Neighbors Networks

Tobias Plötz, Stefan Roth|TUbilio (Technical University of Darmstadt)|Oct 30, 2018
Image and Signal Denoising MethodsComputer Science36 references30 citations
TL;DR

This paper proposes a differentiable, continuous relaxation of the k-nearest neighbors (KNN) selection rule to enable end-to-end training of non-local neural networks. The method introduces the Neural Nearest Neighbors block (N³ block), which leverages self-similarity in data through learnable feature spaces and outperforms CNN and non-local baselines in image denoising and super-resolution, achieving state-of-the-art results on Urban100 and BSD100 datasets.

ABSTRACT

Non-local methods exploiting the self-similarity of natural signals have been well studied, for example in image analysis and restoration. Existing approaches, however, rely on k-nearest neighbors (KNN) matching in a fixed feature space. The main hurdle in optimizing this feature space w.r.t. application performance is the non-differentiability of the KNN selection rule. To overcome this, we propose a continuous deterministic relaxation of KNN selection that maintains differentiability w.r.t. pairwise distances, but retains the original KNN as the limit of a temperature parameter approaching zero. To exploit our relaxation, we propose the neural nearest neighbors block (N3 block), a novel non-local processing layer that leverages the principle of self-similarity and can be used as building block in modern neural network architectures. We show its effectiveness for the set reasoning task of correspondence classification as well as for image restoration, including image denoising and single image super-resolution, where we outperform strong convolutional neural network (CNN) baselines and recent non-local models that rely on KNN selection in hand-chosen features spaces.

Motivation & Objective

  • To overcome the non-differentiability of KNN selection in neural networks, which hinders end-to-end training.
  • To enable optimization of the feature space used for KNN matching, rather than relying on fixed, hand-crafted features.
  • To develop a differentiable, continuous relaxation of KNN that maintains the original KNN behavior in the limit as a temperature parameter approaches zero.
  • To demonstrate the effectiveness of the proposed N³ block in improving performance on image restoration and set reasoning tasks.

Proposed method

  • Proposes a continuous deterministic relaxation of KNN selection using a temperature-controlled softmax over pairwise distances, enabling backpropagation through the selection process.
  • Defines a differentiable neighbor weighting scheme where neighbor weights are computed via a softmin over distances, with the temperature parameter controlling the sharpness of selection.
  • Introduces the N³ block, a learnable neural network layer that applies the relaxed KNN operation to feature maps, aggregating information from similar patches in a differentiable manner.
  • Employs a temperature parameter that allows interpolation between uniform averaging (high temperature) and hard KNN selection (low temperature), with gradients available for optimization.
  • Uses the relaxed KNN operation as a differentiable attention-like mechanism that generalizes standard soft attention and can be stacked in deep networks.
  • Trains the full network end-to-end, jointly optimizing feature extractors, distance metrics, and neighbor aggregation via backpropagation.

Experimental results

Research questions

  • RQ1Can we make KNN selection differentiable to enable end-to-end training in deep neural networks?
  • RQ2Does optimizing the feature space for KNN matching improve performance in image restoration tasks?
  • RQ3Can a differentiable relaxation of KNN outperform fixed-feature non-local methods and strong CNN baselines in image denoising and super-resolution?
  • RQ4How does the learned temperature and neighbor weighting vary across feature hierarchies in deep networks?
  • RQ5Can the N³ block be effectively applied to set-valued data, such as correspondence classification?

Key findings

  • The N³ block achieves a PSNR of 30.80 dB on Urban100 for ×2 super-resolution, outperforming the strong VDSR baseline (30.76 dB) and other non-local methods.
  • For ×4 super-resolution on Urban100, the N³ Net achieves 25.23 dB, surpassing VDSR (25.18 dB) and WSD-SR (25.16 dB), with visually sharper results.
  • On Gaussian denoising with σ=25, the N³ block improves PSNR from 29.74 dB (baseline DnCNN) to 29.99 dB, even when training on larger patches.
  • The network learns to use a sharper (lower temperature) selection in early layers (mean top weight ≈ 0.21) and more uniform weighting in deeper layers (≈ 0.04), indicating hierarchical feature use.
  • The runtime overhead of the full N³ model is 3.5× that of DnCNN, but it achieves significantly better performance than both DnCNN and KNN baselines with similar overhead.
  • In correspondence classification, simply adding the N³ block to a recent neural network baseline leads to significant performance gains, demonstrating its generalizability to set-based tasks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.