All Projects → naturomics → Capsnet Tensorflow

naturomics / Capsnet Tensorflow

Licence: apache-2.0
A Tensorflow implementation of CapsNet(Capsules Net) in paper Dynamic Routing Between Capsules

Programming Languages

python
139335 projects - #7 most used programming language
r
7636 projects

Projects that are alternatives of or similar to Capsnet Tensorflow

CapsNet-tensorflow-jupyter
A simple tensorflow implementation of CapsNet (by Dr. G. Hinton), based on my understanding. This repository is built with an aim to simplify the concept, implement and understand it.
Stars: ✭ 16 (-99.58%)
Mutual labels:  capsule, dynamic-routing, capsnet, capsule-network
Capsnet Keras
A Keras implementation of CapsNet in NIPS2017 paper "Dynamic Routing Between Capsules". Now test error = 0.34%.
Stars: ✭ 2,428 (-35.7%)
Mutual labels:  capsule-network, capsnet, capsule, dynamic-routing
CapsuleLayer
PyTorch Capsule Layer
Stars: ✭ 28 (-99.26%)
Mutual labels:  routing-algorithm, capsule, capsnet
capsnet.mxnet
MXNet implementation of CapsNet
Stars: ✭ 30 (-99.21%)
Mutual labels:  capsule, dynamic-routing, capsnet
Variational Capsule Routing
Official Pytorch code for (AAAI 2020) paper "Capsule Routing via Variational Bayes", https://arxiv.org/pdf/1905.11455.pdf
Stars: ✭ 84 (-97.78%)
Mutual labels:  capsule-network, capsnet
CapsNet
Empirical studies on Capsule Network representation and improvements implemented with PyTorch.
Stars: ✭ 39 (-98.97%)
Mutual labels:  capsnet, capsule-network
heinsen routing
Official implementation of "An Algorithm for Routing Capsules in All Domains" (Heinsen, 2019) in PyTorch.
Stars: ✭ 41 (-98.91%)
Mutual labels:  routing-algorithm, capsule-network
Capsule Gan
Code for my Master thesis on "Capsule Architecture as a Discriminator in Generative Adversarial Networks".
Stars: ✭ 120 (-96.82%)
Mutual labels:  capsule-network, capsnet
capsules-tensorflow
Another implementation of Hinton's capsule networks in tensorflow.
Stars: ✭ 18 (-99.52%)
Mutual labels:  capsnet, capsule-network
Capsnet Traffic Sign Classifier
A Tensorflow implementation of CapsNet(Capsules Net) apply on german traffic sign dataset
Stars: ✭ 166 (-95.6%)
Mutual labels:  capsule-network, capsnet
me recognition
CapsuleNet for Micro-expression Recognition (IEEE FG 2019)
Stars: ✭ 56 (-98.52%)
Mutual labels:  capsule, capsule-network
Capsule Net Pytorch
[NO MAINTENANCE INTENDED] A PyTorch implementation of CapsNet architecture in the NIPS 2017 paper "Dynamic Routing Between Capsules".
Stars: ✭ 158 (-95.82%)
Mutual labels:  capsule-network, capsnet
Capslayer
CapsLayer: An advanced library for capsule theory
Stars: ✭ 351 (-90.7%)
Mutual labels:  capsule-network, capsnet
Capsnet Visualization
🎆 A visualization of the CapsNet layers to better understand how it works
Stars: ✭ 371 (-90.17%)
Mutual labels:  capsule-network, capsnet
dynamic-routing-capsule-cifar
CapsNet reference from : https://github.com/XifengGuo/CapsNet-Keras
Stars: ✭ 34 (-99.1%)
Mutual labels:  capsule
CapsuleGAN
An Experimental Implementation for CapsuleGAN.
Stars: ✭ 22 (-99.42%)
Mutual labels:  capsule
Hands On Deep Learning Algorithms With Python
Master Deep Learning Algorithms with Extensive Math by Implementing them using TensorFlow
Stars: ✭ 272 (-92.8%)
Mutual labels:  capsule-network
EasyRec
A framework for large scale recommendation algorithms.
Stars: ✭ 599 (-84.14%)
Mutual labels:  capsule-network
SegCaps
A Clone version from Original SegCaps source code with enhancements on MS COCO dataset.
Stars: ✭ 62 (-98.36%)
Mutual labels:  capsule
Hands-On-Deep-Learning-Algorithms-with-Python
Hands-On Deep Learning Algorithms with Python, By Packt
Stars: ✭ 76 (-97.99%)
Mutual labels:  capsule-network

CapsNet-Tensorflow

Contributions welcome License Gitter

A Tensorflow implementation of CapsNet based on Geoffrey Hinton's paper Dynamic Routing Between Capsules

capsVSneuron

Notes:

  1. The current version supports MNIST and Fashion-MNIST datasets. The current test accuracy for MNIST is 99.64%, and Fashion-MNIST 90.60%, see details in the Results section
  2. See dist_version for multi-GPU support
  3. Here(知乎) is an article explaining my understanding of the paper. It may be helpful in understanding the code.

Important:

If you need to apply CapsNet model to your own datasets or build up a new model with the basic block of CapsNet, please follow my new project CapsLayer, which is an advanced library for capsule theory, aiming to integrate capsule-relevant technologies, provide relevant analysis tools, develop related application examples, and promote the development of capsule theory. For example, you can use capsule layer block in your code easily with the API capsLayer.layers.fully_connected and capsLayer.layers.conv2d

Requirements

  • Python
  • NumPy
  • Tensorflow>=1.3
  • tqdm (for displaying training progress info)
  • scipy (for saving images)

Usage

Step 1. Download this repository with git or click the download ZIP button.

$ git clone https://github.com/naturomics/CapsNet-Tensorflow.git
$ cd CapsNet-Tensorflow

Step 2. Download MNIST or Fashion-MNIST dataset. In this step, you have two choices:

  • a) Automatic downloading with download_data.py script
$ python download_data.py   (for mnist dataset)
$ python download_data.py --dataset fashion-mnist --save_to data/fashion-mnist (for fashion-mnist dataset)
  • b) Manual downloading with wget or other tools, move and extract dataset into data/mnist or data/fashion-mnist directory, for example:
$ mkdir -p data/mnist
$ wget -c -P data/mnist http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
$ wget -c -P data/mnist http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
$ wget -c -P data/mnist http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
$ wget -c -P data/mnist http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
$ gunzip data/mnist/*.gz

Step 3. Start the training(Using the MNIST dataset by default):

$ python main.py
$ # or training for fashion-mnist dataset
$ python main.py --dataset fashion-mnist
$ # If you need to monitor the training process, open tensorboard with this command
$ tensorboard --logdir=logdir
$ # or use `tail` command on linux system
$ tail -f results/val_acc.csv

Step 4. Calculate test accuracy

$ python main.py --is_training=False
$ # for fashion-mnist dataset
$ python main.py --dataset fashion-mnist --is_training=False

Note: The default parameters of batch size is 128, and epoch 50. You may need to modify the config.py file or use command line parameters to suit your case, e.g. set batch size to 64 and do once test summary every 200 steps: python main.py --test_sum_freq=200 --batch_size=48

Results

The pictures here are plotted by tensorboard and my tool plot_acc.R

  • training loss

total_loss margin_loss reconstruction_loss

Here are the models I trained and my talk and something else:

Baidu Netdisk(password:ahjs)

  • The best val error(using reconstruction)
Routing iteration 1 3 4
val error 0.36 0.36 0.41
Paper 0.29 0.25 -

test_acc

My simple comments for capsule

  1. A new version neural unit(vector in vector out, not scalar in scalar out)
  2. The routing algorithm is similar to attention mechanism
  3. Anyway, a great potential work, a lot to be built upon

My weChat:

my_wechat

Reference

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