Skip to content
Hyperspherical Prototype Networks
Branch: master
Clone or download

Latest commit

psmmettes Update
Fixed small typo in line 1.
Latest commit c5157df Jan 14, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.

Hyperspherical Prototype Networks

This repository contains the PyTorch code for the NeurIPS 2019 paper "Hyperspherical Prototype Networks".
The paper is available here:


The repository includes:

  • Download link for pre-computed prototypes.
  • Classification scripts for CIFAR-100, ImageNet-200, and CUB Birds.
  • Script to construct your own prototypes.
  • Joint classification and regression script for OmniArt.

Downloading and constructing hyperspherical prototypes

To obtain prototypes pre-computed for the paper, perform the following steps:

cd prototypes/
wget -r -nH --cut-dirs=3 --no-parent --reject="index.html*"
cd ..

The folder 'sgd' denotes the prototypes without semantic priors, 'sgd-sem' with semantic priors. The folders 'sem' and 'simplex' denote the baseline prototypes of Table 1.

To create your own prototypes, use the script. An example run for 100 classes and 50 dimensions:

python -c 100 -d 50 -r prototypes/sgd/

In case you want to construct prototypes on CIFAR-100 or ImageNet-200 with word2vec representations, please download the wtv files as follows:

mkdir -p wtv
cd wtv/
wget -r -nH --cut-dirs=3 --no-parent --reject="index.html*"
cd ..

Running hyperspherical prototype networks

To perform classification and joint optimization with Hyperspherical Prototype Networks, use the scripts that start with 'hpn_'.
For CIFAR-100 using 50-dimensional prototypes without semantic priors (akin to column 4 of Table 1 of the paper), run the following:

python --datadir data/ --resdir res/ --hpnfile prototypes/sgd/prototypes-50d-100c.npy --seed 100

All the other scripts work precisely the same.

The CUB Birds dataset can be obtained from the original dataset:
The prepared ImageNet-200 and OmniArt datasets can be obtained as follows:

cd data/
wget -r -nH --cut-dirs=3 --no-parent --reject="index.html*"
wget -r -nH --cut-dirs=3 --no-parent --reject="index.html*"
cd ..

Please cite the paper accordingly:

  title={Hyperspherical Prototype Networks},
  author={Mettes, Pascal and van der Pol, Elise and Snoek, Cees G M},
  booktitle={Advances in Neural Information Processing Systems},
You can’t perform that action at this time.