All Projects → cezannec → Capsule_net_pytorch

cezannec / Capsule_net_pytorch

Licence: mit
Readable implementation of a Capsule Network as described in "Dynamic Routing Between Capsules" [Hinton et. al.]

Projects that are alternatives of or similar to Capsule net pytorch

Captcha break
验证码识别
Stars: ✭ 2,268 (+653.49%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Seq2seq
Tutorials on implementing a few sequence-to-sequence (seq2seq) models with PyTorch and TorchText.
Stars: ✭ 3,418 (+1035.55%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Code Of Learn Deep Learning With Pytorch
This is code of book "Learn Deep Learning with PyTorch"
Stars: ✭ 2,262 (+651.5%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Capsnet Traffic Sign Classifier
A Tensorflow implementation of CapsNet(Capsules Net) apply on german traffic sign dataset
Stars: ✭ 166 (-44.85%)
Mutual labels:  jupyter-notebook, capsule-network
Hands On Deep Learning Algorithms With Python
Master Deep Learning Algorithms with Extensive Math by Implementing them using TensorFlow
Stars: ✭ 272 (-9.63%)
Mutual labels:  jupyter-notebook, capsule-network
Pytorch Practice
Some example scripts on pytorch
Stars: ✭ 166 (-44.85%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Sentiment Analysis
Tutorials on getting started with PyTorch and TorchText for sentiment analysis.
Stars: ✭ 3,209 (+966.11%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Rl
Tutorials for reinforcement learning in PyTorch and Gym by implementing a few of the popular algorithms. [IN PROGRESS]
Stars: ✭ 121 (-59.8%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Image Classification
Tutorials on how to implement a few key architectures for image classification using PyTorch and TorchVision.
Stars: ✭ 272 (-9.63%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Kaggle Starter
Pytorch starter kit for Kaggle competitions
Stars: ✭ 268 (-10.96%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Question Answering
Important paper implementations for Question Answering using PyTorch
Stars: ✭ 154 (-48.84%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Thinking In Tensors Writing In Pytorch
Thinking in tensors, writing in PyTorch (a hands-on deep learning intro)
Stars: ✭ 287 (-4.65%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Applied Dl 2018
Tel-Aviv Deep Learning Boot-camp: 12 Applied Deep Learning Labs
Stars: ✭ 146 (-51.5%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Dive Into Dl Pytorch
本项目将《动手学深度学习》(Dive into Deep Learning)原书中的MXNet实现改为PyTorch实现。
Stars: ✭ 14,234 (+4628.9%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch 101 Tutorial Series
PyTorch 101 series covering everything from the basic building blocks all the way to building custom architectures.
Stars: ✭ 136 (-54.82%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Book deeplearning in pytorch source
Stars: ✭ 236 (-21.59%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorchnlpbook
Code and data accompanying Natural Language Processing with PyTorch published by O'Reilly Media https://nlproc.info
Stars: ✭ 1,390 (+361.79%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Capsule Gan
Code for my Master thesis on "Capsule Architecture as a Discriminator in Generative Adversarial Networks".
Stars: ✭ 120 (-60.13%)
Mutual labels:  jupyter-notebook, capsule-network
Pytorch Cheatsheet
Check out improved:
Stars: ✭ 256 (-14.95%)
Mutual labels:  jupyter-notebook, pytorch-tutorial
Pytorch Lesson Zh
pytorch 包教不包会
Stars: ✭ 279 (-7.31%)
Mutual labels:  jupyter-notebook, pytorch-tutorial

Capsule Network

Readable implementation of a Capsule Network as described in "Dynamic Routing Between Capsules" [Hinton et. al.]

In this notebook, I'll be building a simple Capsule Network that aims to classify MNIST images. This is an implementation in PyTorch and this notebook assumes that you are already familiar with convolutional and fully-connected layers.

What are Capsules?

Capsules are a small group of neurons that have a few key traits:

  • Each neuron in a capsule represents various properties of a particular image part; properties like a parts color, width, etc.
  • Every capsule outputs a vector, which has some magnitude (that represents a part's existence) and orientation (that represents a part's generalized pose).
  • A capsule network is made of multiple layers of capsules; during training, this network aims to learn the spatial relationships between the parts and whole of an object (ex. how the position of eyes and a nose relate to the position of a whole face in an image).
  • Capsules represent relationships between parts of a whole object by using dynamic routing to weight the connections between one layer of capsules and the next and creating strong connections between spatially-related object parts.

You can read more about all of these traits in my blog post about capsules and dynamic routing.

Representing Relationships Between Parts

All of these traits allow capsules to communicate with each other and determine how data moves through them. Using dynamic communication, during the training process, a capsule network learns the spatial relationships between visual parts and their wholes (ex. between eyes, a nose, and a mouth on a face). When compared to a vanilla CNN, this knowledge about spatial relationships makes it easier for a capsule network to identify an object no matter what orientation it is in. These networks are also, generally, better able to identify multiple, overlapping objects, and to learn from smaller sets of training data!


Model Architecture

The Capsule Network that I'll define is made of two main parts:

  1. A convolutional encoder
  2. A fully-connected, linear decoder

The above image was taken from the original Capsule Network paper (Hinton et. al.). The notebook follows the architecture described in that paper and tries to replicate some of the experiments, such as feature visualization, that the authors pursued.


Running Code Locally

If you're interested in running this code on your own computer, there are thorough instructions on setting up anaconda, and downloading PyTorch and the necessary libraries in the readme of Udacity's deep learning repo. After downloading the necessary libraries, you can proceed with cloning and running this code, as usual.

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