Capsules

April 1, 2019 ยท View on GitHub

CapsNet implementations with PyTorch. Randomness in codes is removed.

Requirements

Python 3.5
PyTorch 0.4.1

Dynamic Routing Between Capsules

Sabour S, Frosst N, Hinton G E. Dynamic routing between capsules[C]//Advances in neural information processing systems. 2017: 3856-3866.
With the best hyperparameters on MNIST dataset in the paper, training will takes 5 hours with two GTX 1070.

Best Test Accuracy
Paper99.75%
This implementation with fine-tune99.74%
This implementation99.72%
Implementation by @gram-ai99.70%
Implementation by @XifengGuo99.66%
Implementation by @naturomics99.64%

Matrix capsules with EM routing

Hinton G E, Sabour S, Frosst N. Matrix capsules with EM routing[C]//ICLR 2018.
With the best hyperparameters on smallNORB dataset in the paper, training will takes 40 hours with eight Tesla P40.

Best Test AccuracyTraining Speed
Paper98.2%-
This Implementation90.9%< 1s/iter with 8 Tesla P40
Implementation by @www0wwwjs191.8%25s/iter with 1 Tesla P40