Skip to content
Code for CVPR 2018 paper "Hashing as Tie-Aware Learning to Rank"
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
+demo NUSWIDE NDCG Oct 10, 2018
+eval NUSWIDE NDCG Oct 10, 2018
+imdb update NUSWIDE Jun 30, 2018
+models update NUSWIDE Jun 30, 2018
main update NUSWIDE Jun 30, 2018
util initial release Jun 14, 2018
LICENSE initial release Jun 14, 2018
apr_s_forward.m initial release Jun 14, 2018
ndcgr_s_forward.m NUSWIDE NDCG Oct 10, 2018
run_cifar_s1.m initial release Jun 14, 2018
run_imagenet.m add ImageNet100 Jun 16, 2018
run_nuswide_AP.m update NUSWIDE Jun 30, 2018
run_nuswide_NDCG.m NUSWIDE NDCG Oct 10, 2018
startup.m initial release Jun 14, 2018

Tie-Aware Hashing

This repository contains Matlab implementation for the following paper:

"Hashing as Tie-Aware Learning to Rank",
Kun He, Fatih Cakir, Sarah Adel Bargal, and Stan Sclaroff. IEEE CVPR, 2018 (arXiv)

If you use this code in your research, please cite:

  title={Hashing as Tie-Aware Learning to Rank},
  author={Kun He and Fatih Cakir and Sarah Adel Bargal and Stan Sclaroff},
  booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},


  • Create or symlink a directory cachedir under the root directory to hold experimental results
  • Install or symlink MatConvNet at ./matconvnet (for training CNNs)
  • Install or symlink VLFeat at ./vlfeat. Note: this is only necessary for computing the regular tie-agnostic AP metric. We provide efficient implementation for the tie-aware metrics in +eval.
  • For ImageNet-pretrained models: in the data directory, run to download pretrained CNNs (VGG-F and AlexNet).
  • For CIFAR-10: in data, run This will download the precomputed IMDB format used in our experiments.
  • For NUS-WIDE: see data/NUSWIDE/
  • For ImageNet100: see data/ImageNet/


  • In the root folder, run startup.m
  • To (approximately) replicate results in the paper, run one of the run_*.m files. For example, run_cifar_s1(32) will run the Setting 1 experiment on the CIFAR-10 dataset, with 32-bit hash codes, using the default parameters therein.
  • Alternatively, directly run the files in +demo/ with your parameter choices. See main/get_opts.m for the parameters.


MIT License, see LICENSE


For questions/comments, feel free to contact:


  • We provide simplified versions of tie-aware AP (apr_s_forward.m and apr_s_backward.m) and tie-aware NDCG (ndcgr_s_forward.m and ndcgr_s_backward.m). They attain similar performance compared to the original versions, but are much simpler to implement. The derivations can be found in the appendix of the arxiv version of the paper (v4).
  • This implementation is partly based on MIHash.
You can’t perform that action at this time.