Giter Site home page Giter Site logo

hpn's Introduction

Hyperspherical Prototype Networks

This repository contains the PyTorch code for the NeurIPS 2019 paper "Hyperspherical Prototype Networks".
The paper is available here: https://arxiv.org/abs/1901.10514

Drawing

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*" http://isis-data.science.uva.nl/mettes/hpn/prototypes/
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 prototypes.py script. An example run for 100 classes and 50 dimensions:

python prototypes.py -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*" http://isis-data.science.uva.nl/mettes/hpn/wtv/
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 hpn_cifar.py --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: http://www.vision.caltech.edu/visipedia/CUB-200-2011.html
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*" http://isis-data.science.uva.nl/mettes/hpn/data/imagenet200/
wget -r -nH --cut-dirs=3 --no-parent --reject="index.html*" http://isis-data.science.uva.nl/mettes/hpn/data/omniart/
cd ..

Please cite the paper accordingly:

@inproceedings{mettes2019hyperspherical,
  title={Hyperspherical Prototype Networks},
  author={Mettes, Pascal and van der Pol, Elise and Snoek, Cees G M},
  booktitle={Advances in Neural Information Processing Systems},
  year={2019}
}

hpn's People

Contributors

psmmettes avatar

Stargazers

maoyuanma avatar Green avatar Brown Chen avatar Jiayang Li avatar Zhang Baoming avatar Xin Cai avatar JacobXu avatar Paul Berg avatar  avatar  avatar Luís Felipe Prates Cattelan avatar  avatar Chénglóng Mǎ avatar Alex Shevchenko avatar  avatar Linye Li avatar  avatar  avatar Nam Hyeon-Woo avatar Zhiheng_Ma avatar Nikolaos-Antonios Ypsilantis avatar Piyush Bagad avatar Pan Yonghua avatar Max avatar Emanuel Sanchez Aimar avatar  avatar Rahul Vigneswaran  avatar Stephan Tulkens avatar lizhaoliu avatar Haofei Yu avatar  avatar Ruiqi Long avatar Robert H. Tang avatar mengmeng avatar Kento Nozawa avatar saw avatar Paul Mwaniki avatar Taiki Miyagawa avatar Joris van der Vorst avatar  avatar Matt Shaffer avatar Dun Chen avatar Ailsa3707 avatar 爱可可-爱生活 avatar Luca Antiga avatar Shumin Deng avatar WangZhennan avatar Saul avatar Jinpeng Wang avatar leo avatar Ivan Sosnovik avatar Mahesh Reddy avatar  avatar 杨海宏 avatar Miltiadis (Miltos) Kofinas avatar  avatar Tijs Maas avatar Kaiwen Yuan avatar Gjorgji Strezoski avatar Jacob Pegs avatar xuxu avatar Stuart Farmer avatar Jacob Danovitch avatar I'm LZ avatar

Watchers

 avatar Gjorgji Strezoski avatar paper2code - bot avatar

hpn's Issues

Some qusetions about the implementation of the sematic ranking loss in this code

Q1:

I find the elements in nns and others is useless in the triplets collection
`

for i in xrange(wtvv.shape[0]):

for j in xrange(len(nns[i])):      
 
    for k in xrange(len(others[i])):     
          
        triplets.append([i,j,i,k])        

triplets = np.array(triplets).astype(int)

`

Q2:
The implementation of prototype_loss_sem is different from L_{PI} in the paper. Is this a trick? Could you explain how it works?

.

Hi!Can you post pre-trained code on github? The download link only contains npy files. Thank you.

Missing argument when computing prototypes with word embeddings

Hi, thanks for the nice repo and very interesting paper!

I am trying to recompute the prototypes on CIFAR100 with privileged information, using the following command:
python prototypes.py -c 100 -d 50 -r prototypes/sgd-sem/ -w wtv/cifar100_wtvvectors.npy

but I get this error:
Traceback (most recent call last): File "prototypes.py", line 95, in <module> nns.append(sorder[:args.nn]) AttributeError: 'Namespace' object has no attribute 'nn'

And it seems indeed that argument nn is not defined anywhere...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.