Rethinking Nearest Neighbors for Visual Classification
Not on the map. Why?
Abstract (arXiv)
Neural network classifiers have become the de-facto choice for current "pre-train then fine-tune" paradigms of visual classification. In this paper, we investigate k-Nearest-Neighbor (k-NN) classifiers, a classical model-free learning method from the pre-deep learning era, as an augmentation to modern neural network based approaches. As a lazy learning method, k-NN simply aggregates the distance between the test image and top-k neighbors in a training set. We adopt k-NN with pre-trained visual representations produced by either supervised or self-supervised methods in two steps: (1) Leverage k-NN predicted probabilities as indications for easy vs. hard examples during training. (2) Linearly interpolate the k-NN predicted distribution with that of the augmented classifier. Via extensive experiments on a wide range of classification tasks, our study reveals the generality and flexibility of k-NN integration with additional insights: (1) k-NN achieves competitive results, sometimes even outperforming a standard linear classifier. (2) Incorporating k-NN is especially beneficial for tasks where parametric classifiers perform poorly and / or in low-data regimes. We hope these discoveries will encourage people to rethink the role of pre-deep learning, classical methods in computer vision. Our code is available at: https://github.com/KMnP/nn-revisit.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 61 of its 82 references that are in the map. First posted on arXiv 15 Dec 2021.
Builds on
61 of 82 references.
References · 61
- 2015Deep Residual Learning for Image Recognitioncited by 51,809
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,082
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 11,979
- 2015Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networkscited by 9,617
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
- 2021Masked Autoencoders Are Scalable Vision Learnerscited by 7,339
- 2017Mask R-CNNcited by 7,259
- 2021Emerging Properties in Self-Supervised Vision Transformerscited by 6,893
- 2020Bootstrap your own latent: A new approach to self-supervised Learningcited by 4,712
- 2017Quo Vadis, Action Recognition? A New Model and the Kinetics Datasetcited by 3,259
- 2015Fast R-CNNcited by 2,930
38 more
- 2020Unsupervised Learning of Visual Features by Contrasting Cluster Assignmentscited by 2,845
- 2017Billion-scale similarity search with GPUscited by 2,477
- 2020Improved Baselines with Momentum Contrastive Learningcited by 2,282
- 2013Rich feature hierarchies for accurate object detection and semantic segmentationcited by 2,160
- 2018Unsupervised Feature Learning via Non-Parametric Instance-level Discriminationcited by 1,838
- 2021Barlow Twins: Self-Supervised Learning via Redundancy Reductioncited by 1,818
- 2021An Empirical Study of Training Self-Supervised Vision Transformerscited by 1,610
- 2018Unsupervised Representation Learning by Predicting Image Rotationscited by 1,586
- 2019Self-training with Noisy Student improves ImageNet classificationcited by 1,304
- 2016Colorful Image Colorizationcited by 1,113
- 2014Two-Stream Convolutional Networks for Action Recognition in Videoscited by 1,067
- 2017Revisiting Unreasonable Effectiveness of Data in Deep Learning Eracited by 916
- 2019Self-Supervised Learning of Pretext-Invariant Representationscited by 806
- 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
- 2019Big Transfer (BiT): General Visual Representation Learningcited by 766
- 2020Prototypical Contrastive Learning of Unsupervised Representationscited by 636
- 2018Exploring the Limits of Weakly Supervised Pretrainingcited by 604
- 2020Understanding the Behaviour of Contrastive Losscited by 397
- 2019Large Scale Adversarial Representation Learningcited by 238
- 2015YFCC100M: The New Data in Multimedia Researchcited by 234
- 2019Billion-scale semi-supervised learning for image classificationcited by 232
- 2019Unsupervised Embedding Learning via Invariant and Spreading Instance Featurecited by 231
- 2016Split-Brain Autoencoders: Unsupervised Learning by Cross-Channel Predictioncited by 217
- 2020How Well Do Self-Supervised Models Transfer?cited by 213
- 2020Nearest Neighbor Machine Translationcited by 209
- 2019Local Aggregation for Unsupervised Learning of Visual Embeddingscited by 204
- 2018Deep k-Nearest Neighbors: Towards Confident, Interpretable and Robust Deep Learningcited by 203
- 2019Scaling and Benchmarking Self-Supervised Visual Representation Learningcited by 201
- 2019SimpleShot: Revisiting Nearest-Neighbor Classification for Few-Shot Learningcited by 194
- 2018Large Scale Fine-Grained Categorization and Domain-Specific Transfer Learningcited by 174
- 2021Benchmarking Representation Learning for Natural World Image Collectionscited by 167
- 2016End-to-end Learning of Deep Visual Representations for Image Retrievalcited by 122
- 2021Self-Supervised Learning with Swin Transformerscited by 121
- 2018Neural Nearest Neighbors Networkscited by 98
- 2019ClusterFit: Improving Generalization of Visual Representationscited by 82
- 2019When Does Self-supervision Improve Few-shot Learning?cited by 78
- 2017Fine-Grained Car Detection for Visual Census Estimationcited by 76
- 2020MoPro: Webly Supervised Learning with Momentum Prototypescited by 66
50 most cited of 61 All 61 (JSON)
Built on by
Citing papers per year: 2022: 1; 2023: 3; 2024: 1; 2025: 1.
6 papers.
- 2023TabR: Tabular Deep Learning Meets Nearest Neighbors in 2023cited by 73
- 2022Test-Time Adaptation via Self-Training with Nearest Neighbor Informationcited by 64
- 2024Beyond Concept Bottleneck Models: How to Make Black Boxes Intervenable?cited by 28
- 2023PARTICLE: Part Discovery and Contrastive Learning for Fine-grained Recognitioncited by 5
- 2023FIANCEE: Faster Inference of Adversarial Networks via Conditional Early Exitscited by 3
- 2025Memory-Modular Classification: Learning to Generalize with Memory Replacementcited by 0
- 2025Memory-Modular Classification: Learning to Generalize with Memory Replacement8 Apr 2025
- 2024Beyond Concept Bottleneck Models: How to Make Black Boxes Intervenable?24 Jan 2024
- 2023PARTICLE: Part Discovery and Contrastive Learning for Fine-grained Recognition25 Sep 2023
- 2023TabR: Tabular Deep Learning Meets Nearest Neighbors in 202326 Jul 2023
- 2023FIANCEE: Faster Inference of Adversarial Networks via Conditional Early Exits20 Apr 2023
- 2022Test-Time Adaptation via Self-Training with Nearest Neighbor Information8 Jul 2022