NNM: Nearest Neighbor Matching for Deep Clustering.

December 15, 2021 ยท View on GitHub

Forked from SCAN (https://github.com/wvangansbeke/Unsupervised-Classification).

Introduction

The illustration of our idea. We propose to match more semantically nearest neighbors from between local (batch) and global (overall) level. Benefit from the dynamic updated deep features with iteration and epoch increases, we can construct more and more semantically confident sample pairs from samples and its neighbors.

Framework

Local Nearest Neighbor Matching

Global Nearest Neighbor Matching

For specifical loss, please refer paper and poster.

Main Results

Pre-Trained Models

ModelsLinks
CIFAR-10Google Drive
CIFAR-20Google Drive
STL-10Google Drive

Trained Models

ModelsACCLinks
CIFAR-100.8430Google Drive
CIFAR-200.4773Google Drive
STL-100.8084Google Drive

Run

Requirements

Python 3.7 and Pytorch 1.4.0 are required. Please refer to requirements.yaml for more details.

Usages

Clone this repo: git clone https://github.com/ZhiyuanDang/NNM.git.

Download datasets: CIFAR-10/100, STL-10.

We can directly use the pre-text model from SCAN. Then, we only need to generate the neighbors by the code

python simclr.py --config_env configs/env.yml --config_exp configs/pretext/simclr_cifar10.yml.

Next, we run the clustering step (optional):

python scan.py --config_env configs/env.yml --config_exp configs/scan/scan_cifar10.yml --gpus 0 (--seed 1234).

Visualizing the top-k images is easily done by setting the --visualize_prototypes flag.

For example on cifar-10: python eval.py --config_exp configs/scan/scan_cifar10.yml --model $MODEL_PATH --visualize_prototypes.

And the Top-3 images is:

However, due to issues in SCAN, self-label is not suitable for NNM. Thus, we remove this file.

Citation

@InProceedings{Dang_2021_CVPR,
    author    = {Dang, Zhiyuan and Deng, Cheng and Yang, Xu and Wei, Kun and Huang, Heng},
    title     = {Nearest Neighbor Matching for Deep Clustering},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {13693-13702}
}

Reference

SpCL (https://github.com/yxgeee/SpCL)