Skip to content
Official Pytorch Implementation for ICML'19 paper: Unsupervised Deep Learning by Neighbourhood Discovery
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
configs upload requirements.yaml, refine readme and update configs for reprod… Apr 25, 2019
datasets deploy Apr 24, 2019
docs upload pretrained models Jun 21, 2019
lib deploy Apr 24, 2019
models deploy Apr 24, 2019
packages deploy Apr 24, 2019 fixed bugs in logs May 30, 2019
requirements.yaml upload requirements.yaml, refine readme and update configs for reprod… Apr 25, 2019

AND: Anchor Neighbourhood Discovery

Accepted by 36th International Conference on Machine Learning (ICML 2019).

Pytorch implementation of Unsupervised Deep Learning by Neighbourhood Discovery.


  • We propose the idea of exploiting local neighbourhoods for unsupervised deep learning. This strategy preserves the capability of clustering for class boundary inference whilst minimising the negative impact of class inconsistency typically encountered in clusters.
  • We formulate an Anchor Neighbourhood Discovery (AND) approach to progressive unsupervised deep learning. The AND model not only generalises the idea of sample specificity learning, but also additionally considers the originally missing sample-to-sample correlation during model learning by a novel neighbourhood supervision design.
  • We further introduce a curriculum learning algorithm to gradually perform neighbourhood discovery for maximising the class consistency of neighbourhoods therefore enhancing the unsupervised learning capability.

Main results

The proposed AND model was evaluated on four object image classification datasets including CIFAR 10/100, SVHN and ImageNet12. Results are shown at the following tables:



Python 2.7 and Pytorch 1.0 are required. Please refer to /path/to/AND/requirements.yaml for other necessary modules. Conda environment we used for the experiments can also be rebuilt according to it.


  1. Clone this repo: git clone
  2. Download datasets and store them in /path/to/AND/data. (Soft link is recommended to avoid redundant copies of datasets)
  3. To reproduce our reported result of ResNet18 on CIFAR10, please use the following command:python --cfgs configs/base.yaml configs/cifar10.yaml
  4. Running on GPUs: code will be run on CPU by default, use this flag to specify the gpu devices which you want to use
  5. To evaluate trained models, use --resume to set the path of the generated checkpoint file and use --test-only flag to exit the program after evaluation

Every time the is run, a new session will be started with the name of current timestamp and all the related files will be stored in folder sessions/timestamp/ including checkpoints, logs, etc.

Pre-trained model

To play with the pre-trained model, please go to ResNet18 / AlexNet. A few things need to be noticed:

  • The model is saved in pytorch format
  • It expects RGB images that their pixel values are normalised with the following mean RGB values mean=[0.485, 0.456, 0.406] and std RGB values std=[0.229, 0.224, 0.225]. Prior to normalisation the range of the image values must be [0.0, 1.0].


This project is licensed under the MIT License. You may find out more here.


If you use this code, please cite the following paper:

Jiabo Huang, Qi Dong, Shaogang Gong and Xiatian Zhu. "Unsupervised Deep Learning by Neighbourhood Discovery." Proc. ICML (2019).

  title={Unsupervised Deep Learning by Neighbourhood Discovery},
  author={Jiabo Huang, Qi Dong, Shaogang Gong and Xiatian Zhu},
  booktitle={Proceedings of the International Conference on machine learning (ICML)},
You can’t perform that action at this time.