All Projects → gram-ai → Capsule Networks

gram-ai / Capsule Networks

A PyTorch implementation of the NIPS 2017 paper "Dynamic Routing Between Capsules".

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Capsule Networks

Tsne Cuda
GPU Accelerated t-SNE for CUDA with Python bindings
Stars: ✭ 1,120 (-30.78%)
Mutual labels:  mnist
Fashion Mnist
A MNIST-like fashion product database. Benchmark 👇
Stars: ✭ 9,675 (+497.96%)
Mutual labels:  mnist
Tf Exercise Gan
Tensorflow implementation of different GANs and their comparisions
Stars: ✭ 110 (-93.2%)
Mutual labels:  mnist
Keras Mnist Center Loss With Visualization
An implementation for mnist center loss training and visualization
Stars: ✭ 69 (-95.74%)
Mutual labels:  mnist
Ml code
A repository for recording the machine learning code
Stars: ✭ 75 (-95.36%)
Mutual labels:  mnist
Generative Models
Comparison of Generative Models in Tensorflow
Stars: ✭ 96 (-94.07%)
Mutual labels:  mnist
Multidigitmnist
Combine multiple MNIST digits to create datasets with 100/1000 classes for few-shot learning/meta-learning
Stars: ✭ 48 (-97.03%)
Mutual labels:  mnist
Ti Pooling
TI-pooling: transformation-invariant pooling for feature learning in Convolutional Neural Networks
Stars: ✭ 119 (-92.65%)
Mutual labels:  mnist
Emnist
A project designed to explore CNN and the effectiveness of RCNN on classifying the EMNIST dataset.
Stars: ✭ 81 (-94.99%)
Mutual labels:  mnist
Mnist Classification
Pytorch、Scikit-learn实现多种分类方法,包括逻辑回归(Logistic Regression)、多层感知机(MLP)、支持向量机(SVM)、K近邻(KNN)、CNN、RNN,极简代码适合新手小白入门,附英文实验报告(ACM模板)
Stars: ✭ 109 (-93.26%)
Mutual labels:  mnist
Label Embedding Network
Label Embedding Network
Stars: ✭ 69 (-95.74%)
Mutual labels:  mnist
Ios Coreml Mnist
Real-time Number Recognition using Apple's CoreML 2.0 and MNIST -
Stars: ✭ 74 (-95.43%)
Mutual labels:  mnist
Matex
Machine Learning Toolkit for Extreme Scale (MaTEx)
Stars: ✭ 104 (-93.57%)
Mutual labels:  mnist
Deeplearning
Deep Learning From Scratch
Stars: ✭ 66 (-95.92%)
Mutual labels:  mnist
Dni.pytorch
Implement Decoupled Neural Interfaces using Synthetic Gradients in Pytorch
Stars: ✭ 111 (-93.14%)
Mutual labels:  mnist
Pytorch Classification Uncertainty
This repo contains a PyTorch implementation of the paper: "Evidential Deep Learning to Quantify Classification Uncertainty"
Stars: ✭ 59 (-96.35%)
Mutual labels:  mnist
Pytorch
PyTorch tutorials A to Z
Stars: ✭ 87 (-94.62%)
Mutual labels:  mnist
Tensorflow Mnist Cgan Cdcgan
Tensorflow implementation of conditional Generative Adversarial Networks (cGAN) and conditional Deep Convolutional Adversarial Networks (cDCGAN) for MANIST dataset.
Stars: ✭ 122 (-92.46%)
Mutual labels:  mnist
Gpnd
Generative Probabilistic Novelty Detection with Adversarial Autoencoders
Stars: ✭ 112 (-93.08%)
Mutual labels:  mnist
Keras Cloud Ml Engine
Adventures using keras on Google's Cloud ML Engine
Stars: ✭ 106 (-93.45%)
Mutual labels:  mnist

Dynamic Routing Between Capsules

A barebones CUDA-enabled PyTorch implementation of the CapsNet architecture in the paper "Dynamic Routing Between Capsules" by Kenta Iwasaki on behalf of Gram.AI.

Training for the model is done using TorchNet, with MNIST dataset loading and preprocessing done with TorchVision.

Description

A capsule is a group of neurons whose activity vector represents the instantiation parameters of a specific type of entity such as an object or object part. We use the length of the activity vector to represent the probability that the entity exists and its orientation to represent the instantiation paramters. Active capsules at one level make predictions, via transformation matrices, for the instantiation parameters of higher-level capsules. When multiple predictions agree, a higher level capsule becomes active. We show that a discrimininatively trained, multi-layer capsule system achieves state-of-the-art performance on MNIST and is considerably better than a convolutional net at recognizing highly overlapping digits. To achieve these results we use an iterative routing-by-agreement mechanism: A lower-level capsule prefers to send its output to higher level capsules whose activity vectors have a big scalar product with the prediction coming from the lower-level capsule.

Paper written by Sara Sabour, Nicholas Frosst, and Geoffrey E. Hinton. For more information, please check out the paper here.

Requirements

  • Python 3
  • PyTorch
  • TorchVision
  • TorchNet
  • TQDM
  • Visdom

Usage

Step 1 Adjust the number of training epochs, batch sizes, etc. inside capsule_network.py.

BATCH_SIZE = 100
NUM_CLASSES = 10
NUM_EPOCHS = 30
NUM_ROUTING_ITERATIONS = 3

Step 2 Start training. The MNIST dataset will be downloaded if you do not already have it in the same directory the script is run in. Make sure to have Visdom Server running!

$ sudo python3 -m visdom.server & python3 capsule_network.py

Benchmarks

Highest accuracy was 99.7% on the 443rd epoch. The model may achieve a higher accuracy as shown by the trend of the test accuracy/loss graphs below.

Training progress.

Default PyTorch Adam optimizer hyperparameters were used with no learning rate scheduling. Epochs with batch size of 100 takes ~3 minutes on a Razer Blade w/ GTX 1050 and ~2 minutes on a NVIDIA Titan XP

TODO

  • Extension to other datasets apart from MNIST.

Credits

Primarily referenced these two TensorFlow and Keras implementations:

  1. Keras implementation by @XifengGuo
  2. TensorFlow implementation by @naturomics

Many thanks to @InnerPeace-Wu for a discussion on the dynamic routing procedure outlined in the paper.

Contact/Support

Gram.AI is currently heavily developing a wide number of AI models to be either open-sourced or released for free to the community, hence why we cannot guarantee complete support for this work.

If any issues come up with the usage of this implementation however, or if you would like to contribute in any way, please feel free to send an e-mail to [email protected] or open a new GitHub issue on this repository.

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].