Home

Awesome

capsules-tensorflow

Another implementation of Hinton's capsule networks in tensorflow. At the moment the implementation provides the means to set up the model presented in Dynamic Routing Between Capsules.

Results:

Results of this implementation on MNIST with batch size 256, learning rate decay 0.95, regularization weight 0.4:

EpochsRouting IterationsRegularizationAccuracy
201Off99.51%
201On99.62%
203Off99.30%
203On99.47%
5001On99.55%
5003On99.50%

Here are some reconstructions of testset digits obtained by the encoder of a capsnet trained on MNIST for 20 and 100 epochs with regularization and iter_routing=2:

<img src="https://github.com/chrislybaer/capsules-tensorflow/blob/master/results/results_20epochs.png" width="280" heigth="570"> <img src="https://github.com/chrislybaer/capsules-tensorflow/blob/master/results/results_100epochs.png" width="280" heigth="570">

The odd lines contain the input digits and the even lines the reconstructed digits. For the reconstruction the orientation of the longest DigitCapsule vector is used.

Reconstructions for the fashion MNIST dataset after 10 epochs with regularization and iter_routing=2:

<img src="https://github.com/chrislybaer/capsules-tensorflow/blob/master/results/results_10epochs_fmnist.png" width="280" heigth="570">

Implemented:

TODO:

For a minimal example please have a look at: main_mnist_capsnet.py. In this file a CapsNet with the architecture proposed in the linked paper is trained on the MNIST dataset.

I am new to tensorflow, therefore, feedback regarding coding style or mistakes is appreciated!

Other Implementations:

<!-- Title: Capsule Networks Description: A tensorflow implementation of Hinton's capsule networks. --> <meta name='keywords' content='capsules, hinton, capsnet, capsules tensorflow, capsnet tensorflow'>