All Projects → shinseung428 → Capsnet_tensorflow

shinseung428 / Capsnet_tensorflow

Licence: mit

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Capsnet tensorflow

Theano Xnor Net
Theano implementation of XNOR-Net
Stars: ✭ 23 (-68.06%)
Mutual labels:  mnist
Capsgnn
A PyTorch implementation of "Capsule Graph Neural Network" (ICLR 2019).
Stars: ✭ 1,008 (+1300%)
Mutual labels:  capsule-network
Pytorch Classification Uncertainty
This repo contains a PyTorch implementation of the paper: "Evidential Deep Learning to Quantify Classification Uncertainty"
Stars: ✭ 59 (-18.06%)
Mutual labels:  mnist
Keract
Layers Outputs and Gradients in Keras. Made easy.
Stars: ✭ 860 (+1094.44%)
Mutual labels:  mnist
Deep Generative Models
Deep generative models implemented with TensorFlow 2.0: eg. Restricted Boltzmann Machine (RBM), Deep Belief Network (DBN), Deep Boltzmann Machine (DBM), Convolutional Variational Auto-Encoder (CVAE), Convolutional Generative Adversarial Network (CGAN)
Stars: ✭ 34 (-52.78%)
Mutual labels:  mnist
Ml In Tf
Get started with Machine Learning in TensorFlow with a selection of good reads and implemented examples!
Stars: ✭ 45 (-37.5%)
Mutual labels:  mnist
Aoe
AoE (AI on Edge,终端智能,边缘计算) 是一个终端侧AI集成运行时环境 (IRE),帮助开发者提升效率。
Stars: ✭ 759 (+954.17%)
Mutual labels:  mnist
Keras Mnist Center Loss With Visualization
An implementation for mnist center loss training and visualization
Stars: ✭ 69 (-4.17%)
Mutual labels:  mnist
Relativistic Average Gan Keras
The implementation of Relativistic average GAN with Keras
Stars: ✭ 36 (-50%)
Mutual labels:  mnist
Nn encapsulation
Capsule research with our trivial contribution
Stars: ✭ 53 (-26.39%)
Mutual labels:  capsule-network
Randwire tensorflow
tensorflow implementation of Exploring Randomly Wired Neural Networks for Image Recognition
Stars: ✭ 29 (-59.72%)
Mutual labels:  mnist
Neural Network From Scratch
Implementation of a neural network from scratch in python.
Stars: ✭ 32 (-55.56%)
Mutual labels:  mnist
Multidigitmnist
Combine multiple MNIST digits to create datasets with 100/1000 classes for few-shot learning/meta-learning
Stars: ✭ 48 (-33.33%)
Mutual labels:  mnist
Mnist Ewc
Implementation of ews weight constraint mentioned in recent Deep Mind paper: http://www.pnas.org/content/early/2017/03/13/1611835114.full.pdf
Stars: ✭ 9 (-87.5%)
Mutual labels:  mnist
Tsne Cuda
GPU Accelerated t-SNE for CUDA with Python bindings
Stars: ✭ 1,120 (+1455.56%)
Mutual labels:  mnist
Awesome Capsule Networks
A curated list of awesome resources related to capsule networks
Stars: ✭ 896 (+1144.44%)
Mutual labels:  capsule-network
Svhn Cnn
Google Street View House Number(SVHN) Dataset, and classifying them through CNN
Stars: ✭ 44 (-38.89%)
Mutual labels:  mnist
Label Embedding Network
Label Embedding Network
Stars: ✭ 69 (-4.17%)
Mutual labels:  mnist
Deeplearning
Deep Learning From Scratch
Stars: ✭ 66 (-8.33%)
Mutual labels:  mnist
Lung Diseases Classifier
Diseases Detection from NIH Chest X-ray data
Stars: ✭ 52 (-27.78%)
Mutual labels:  capsule-network

Testing Capsule Network on various datasets

This repository contains different tests performed on a capsule network model.

Test 1 : Capsule Network on mnist dataset
Test 2 : Capsule Network on fashion_mnist dataset
Test 3 : Capsule Network on small_norb dataset
Test 3 : Capsule Network on cifar10 dataset
Test 4 : Robustness of Capsule Network on randomly rotated mnist datset
Test 5 : Robustness of Capsule Network on affine transformation

Available dataset

data folder setting

-data
  -mnist
    -t10k-images.idx3-ubyte
    -t10k-labels.idx1-ubyte
    -train-images.idx3-ubyte
    -train-labels.idx1-ubyte
  -fashion-mnist
    -fashion-mnist_test.csv
    -fashion-mnist_train.csv
    -t10k-images-idx3-ubyte
    -t10k-labels-idx1-ubyte
    -train-images-idx3-ubyte
    -train-labels-idx1-ubyte
  -affnist
    -test
      -1.mat
      -2.mat
      -...
    -train
      -1.mat
      -2.mat
      -...
  -small_norb
    -smallnorb-5x46789x9x18x6x2x96x96-training-dat.mat
    -smallnorb-5x46789x9x18x6x2x96x96-training-cat.mat
    -smallnorb-5x01235x9x18x6x2x96x96-testing-dat.mat
    -smallnorb-5x01235x9x18x6x2x96x96-testing-cat.mat
  -cifar10
    -batches.meta
    -data_batch_1
    -...
    -test_batch

Network Model

  • baseline_network (Convolutional Neural Network as described in CapsNet paper)
  • capsule_dynamic (Capsule Network with Dynamic Routing)
  • capsule_em (Coming soon)

Requirements

  • python 2.7
  • Tensorflow 1.3
  • scipy

How to run Training & Testing

Example code to train the capsule_dynamic(CapsNet with dynamic routing) model on mnist dataset.

$ python main.py --model=capsule_dynamic --data=mnist

Example code to test the capsule_dynamic(CapsNet with dynamic routing) model on mnist dataset.

$ python main.py --is_train=False --model=capsule_dynamic --data=mnist

Other models can be trained/tested by changing the name of the --model flag, and other datasets can be used by changing the name of the --data flag.

Test 1 (mnist -> mnist)

Code to run the test

$ python main.py --model=capsule_dynamic --data=mnist 
$ python main.py --is_train=False --model=capsule_dynamic --data=mnist 

Trained mnist images Alt text Reconstructed mnist images Alt text

Model Parameters Test Accuracy
baseline_network 13.2M 99.03 %
capsule_dynamic 8.2M 99.25 %

Both baseline_network and capsule_dynamic network achieved above 99% accuracy on the mnist dataset.

Test 2 (fashion-mnist -> fashion-mnist)

Code to run the test

$ python main.py --model=capsule_dynamic --data=fashion-mnist 
$ python main.py --is_train=False --model=capsule_dynamic --data=fashion-mnist 

Trained fashion-mnist images Alt text Reconstructed fashion-mnist images Alt text

Model Parameters Test Accuracy
baseline_network 13.2M 89.94%
capsule_dynamic 8.2M 89.02%

Both baseline_network and capsule_dynamic networks achieved about 89% accuracy on the fashion-mnist dataset. This result was obtained after training the network for 5 epochs. Higher accuracy is expected when the network is trained more than 5 epochs.

Test 3 (smallNORB(random crop) -> smallNORB(center crop))

size of the input(in main.py) should be changed to 32x32 before running this test
Code to run the test

$ python main.py --model=capsule_dynamic --data=small_norb
$ python main.py --is_train=False --model=capsule_dynamic --data=small_norb

Trained randomly cropped 32x32 small_norb images Alt text Tested center cropped 32x32 small_norb images Alt text

Model Parameters Test Accuracy
baseline_network 19.3M 99.16%
capsule_dynamic 8.3M 99.56%

Test 4 (cifar10 -> cifar10)

size of the input(in main.py) should be changed to 32x32 before running this test
Code to run the test

$ python main.py --model=capsule_dynamic --data=cifar10
$ python main.py --is_train=False --model=capsule_dynamic --data=cifar10

Trained randomly cropped 32x32 cifar10 images Alt text Tested center cropped 32x32 cifar10 images Alt text

Model Parameters Test Accuracy
baseline_network 19.3M 67.42%
capsule_dynamic 11.7M 69.82%

Test 5 (mnist -> mnist(rotated))

Code to run the test

$ python main.py --model=capsule_dynamic --data=mnist
$ python main.py --is_train=False --model=capsule_dynamic --data=mnist --rotate=True

Trained mnist images Alt text Tested randomly rotated mnist images Alt text

Model Parameters Test Accuracy
baseline_network 13.2M 74.10 %
capsule_dynamic 8.2M 77.68 %

The baseline_network(CNN) and capsule_dynamic(CapsNet with dynamic routing) models were first trained on the normal 28x28 mnist dataset. Both network achieved high accuracy on the test set (both close to 99%).

Two models were then tested on randomly rotated(-30 to +30) mnist test set. The baseline_network achieved 74.10% accuracy and a capsule_dynamic model achieved 77.68% accuracy.

Test 6 (mnist -> affnist)

size of the input(in main.py) should be changed to 40x40 before running this test
Code to run the test

$ python main.py --model=capsule_dynamic --data=mnist --random_pos=True
$ python main.py --is_train=False --model=capsule_dynamic --data=affnist

Trained randomly positioned 40x40 mnist images Alt text Tested 40x40 affnist images Alt text

Model Parameters Test Accuracy
baseline_network 35.4M 61.70 %
capsule_dynamic 13.5M 75.89 %

This test runs two models on 40x40 randomly placed mnist images. No affine transformation is applied other than translation and natural transformation seen in the standard mnist. This test is performed to test the robustness of the capsule network to affine transformations.

Comparing the baseline network with capsule network with dynamic routing shows similar result as mentioned in the CapsNet paper. The baseline network achieves 61.70% accuracy and the capsule network achieves 75.89% accuray.

ToDo

  • Implement Matrix Capsules with EM Routing
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].