The repository builds approximate k-nearest neighbour classifiers from CIFAR-10. We use a trivial k-NN classifier using
We use approximate k-NN methods from the faiss library as exact NN search is very slow. We also sweep over different values of
Index | no_aug | basic_aug | adv_aug | adv_aug + mixup |
---|---|---|---|---|
ivfpq(10,32,8), nprobe=1 | 0.3915 (k=16) | 0.4460 (k=90) | 0.4762 (k=200) | 0.4914 (k=70) |
ivfpq(10,32,8), nprobe=10 | 0.4097 (k=12) | 0.4593 (k=90) | 0.4880 (k=200) | 0.5015 (k=200) |
The experiments were conveived by Suriya Gunasekar and Nati Srebro. Tal Wagner helped with the implementation. We thank the open source libraries faiss and timm, which this repository builds from.
- This implementation is not optimized wrt memory and efficiency for datasets larger than CIFAR-10
- Check requirements.txt file for required packages
- The code uses faiss library for fast approximate nearest neighbor implementation, and timm for implementations of advanced augmentations and mixup. Please check documentations therein for additional information.
- Check commanline options and default options in
config.py
--basic-augmentation
uses horizontal flip and random crop with 4 pixel padding. For each training image, -- all combinations are included in building the ann classifier--advanced-augmentation
uses basic augmentation, along with RandAugment, RandomErasing. For each training image--epochs
number of random transforms from this list are included in the ann classifier.--use-mixup
creates ANN model on the space of images obtained after mixup/cutmix preprocessing from batches of data--indexes
single or list of faiss indices to use for ann algorithm. Check faiss library documentation for descriptions of the different options.
- Optionally, edit default options to your preference
- Run
main.py
with appropriate commanline arguments, e.g.,python main.py --indexes ivfpq
for no augmentationpython main.py --indexes ivfpq --advanced-augmentation --use-mixup --pca 100