All Projects → wy1iu → MHE

wy1iu / MHE

Licence: MIT license
Implementation for <Learning towards Minimum Hyperspherical Energy> in NIPS'18.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to MHE

CasADi MPC MHE Python
This repository is an implementation of the work from Mohamed W. Mehrez. I convert the original code in MATLAB to the Python
Stars: ✭ 44 (-42.86%)
Mutual labels:  mhe
WSDEC
Weakly Supervised Dense Event Captioning in Videos, i.e. generating multiple sentence descriptions for a video in a weakly-supervised manner.
Stars: ✭ 95 (+23.38%)
Mutual labels:  nips-2018
SphereFace-TensorFlow
A TensorFlow implementation for SphereFace!The code can be trained on LFW.
Stars: ✭ 17 (-77.92%)
Mutual labels:  sphereface
FaceRecognition PyTorch
Implement Face Recognition Code in PyTorch. Such as SphereFace with A-Softmax.
Stars: ✭ 29 (-62.34%)
Mutual labels:  sphereface
Sphereface
Implementation for <SphereFace: Deep Hypersphere Embedding for Face Recognition> in CVPR'17.
Stars: ✭ 1,483 (+1825.97%)
Mutual labels:  sphereface
awesome-face-recognition
this repo include paper review, code in face recognition
Stars: ✭ 16 (-79.22%)
Mutual labels:  sphereface

Learning towards Minimum Hyperspherical Energy

By Weiyang Liu*, Rongmei Lin*, Zhen Liu*, Lixin Liu*, Zhiding Yu, Bo Dai, Le Song

License

MHE and SphereFace+ are released under the MIT License (refer to the LICENSE file for details).

Contents

  1. Introduction
  2. Citation
  3. Requirements
  4. Usage
  5. Results
  6. SphereFace+ for face recognition
  7. Generative Adversarial Networks with MHE
  8. Note

Introduction

The repository contains the tensorflow implementation of Minimum Hyperspherical Energy (MHE) and Caffe implementation of SphereFace+. Inspired by a well-known Physics problem (Thomson problem), MHE is formulated as an energy on a hypersphere. Minimizing it can achieve better generalization in various applications. In general, MHE serves as a simple plug-in regularization for neural networks, which enchances the neuron diversity on hyperspheres (i.e., angular diversity) and is able to consistently improve the network's generalization ability in various application. Our paper is published in NIPS 2018 and is available at arXiv.

Citation

If you find our work useful in your research, please consider to cite:

@article{LiuNIPS18,
  title={Learning towards Minimum Hyperspherical Energy},
  author={Liu, Weiyang and Lin, Rongmei and Liu, Zhen and Liu, Lixin and Yu, Zhiding and Dai, Bo and Song, Le},
  journal={NIPS},
  year={2018}
  }

Requirements

  1. Python 3.6 (Python 2.7 needs to modify the unpickle funtion in train.py)
  2. TensorFlow
  3. Keras (for MHE-GAN)
  4. numpy

Usage

Part 1: Clone the repositary

  • Clone the repositary.

    git clone https://github.com/wy1iu/MHE.git

Part 2: Download CIFAR-100 training and testing data

  • For the current code, we use our own data pre-processing code, and it is the standard pre-processing for CIFAR-100. The training and testing data can be downloaded via Google Drive. Users should put the downloaded data to the MHE_ROOT directory.

Part 3: CIFAR-100

  • Train and test the model with the following code:

    cd $MHE_ROOT/code
    python train.py --model_name=mhe --power_s=0
  • The parameters include model_name: [baseline, mhe, half_mhe] and power_s: [0, 1, 2, a0, a1, a2]. mhe denotes the full-space MHE regularization, half_mhe represents the half-space MHE, and power_s is the parameter s (see equation 1 in the paper) to control the formulation of MHE (0,1,2 are the Euclidean distance, and a0,a1,a2 use the angles).

  • For different datasets, you may need adjuest to hyperparameter for the entire MHE regularizaiton.

Results

  • See the log folder for the expected results.

SphereFace-plus

SphereFace+ is an improved deep face recognition algorithm based on SphereFace. We incorporate the MHE regularization to the original SphereFace and further boost the recognition accuracy. SphereFace+ is implemented in Caffe and therefore is independently host here. An PyTorch version is available in OpenSphere.

MHE-GAN

To train a model from scratch, simply run python train.py. To test the best models we provide, run python test.py.

For the model trained with both MHE (magnitude 1e-7) and spectral normalization (located in MHE-GAN/sn-model), we obtained the inception score of 7.68, which is much higher than we originally reported in the paper. In contrast, the same GAN with only spectral normalization yields 7.4 inception score and the baseline GAN only achieves 6.64.

For the model trained with only MHE (magnitude 1e-6, located in MHE-GAN/non-sn-model), we obtained the inception score of 7.48, which is also much higher than we originally reported in the paper.

The weight files of the MHE+SN model with inception score 7.68 and the MHE-only model with inception score 7.48 are provided at Google Drive. Please place the model files under the snapshots folder in the corresponding experiment folders.

The following table summarizes the results:

Model Inception Score Weights
Baseline GAN 6.64 N/A
GAN w/ Spectral Norm 7.40 N/A
GAN w/ MHE 7.48 Google Drive
GAN w/ Spectral Norm & MHE 7.68 Google Drive

Some random samples of the generated images from MHE-GAN (MHE+SN) is shown as follows:

Note

  • The code was tested on tensorflow of versions >= 1.10. For earlier versions, the code for computing inception score might report wrong inception scores due to bugs in tf.contrib.gan.
  • Surprisingly, we found that using Titan Xp to run our code gives better performance on CIFAR-10 than using GTX 1080. Note that, the experiments in the paper are mostly run by Titan Xp.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].