Dynamic Routing Between Capsules
Sara Sabour, Nicholas Frosst, Geoffrey E Hinton

TL;DR
This paper introduces a capsule network architecture that uses dynamic routing to improve recognition of overlapping objects, achieving state-of-the-art results on MNIST by modeling hierarchical relationships more effectively.
Contribution
The paper proposes a novel capsule network with dynamic routing that better captures hierarchical pose relationships and improves recognition accuracy over traditional convolutional networks.
Findings
State-of-the-art performance on MNIST
Superior recognition of overlapping digits
Effective hierarchical pose modeling
Abstract
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 an 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 parameters. 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…
| \pbox 1cmInput | ||||||
| Output |
|
|
|
|
|
|
| Method | Routing | Reconstruction | MNIST (%) | MultiMNIST (%) |
|---|---|---|---|---|
| Baseline | - | - | ||
| CapsNet | 1 | no | - | |
| CapsNet | 1 | yes | ||
| CapsNet | 3 | no | - | |
| CapsNet | 3 | yes |
| Scale and thickness |
|
|---|---|
| Localized part |
|
| Stroke thickness |
|
| Localized skew |
|
| Width and translation |
|
| Localized part |
|
| R: | R: | R: | R: | *R: | *R: | R: | R:P: |
| L: | L: | L: | L: | L: | L: | L: | L: |
|
|
|
||||||
| R: | R: | R: | R: | *R: | *R: | R: | R:P: |
| L: | L: | L: | L: | L: | L: | L: | L: |
|
|
|
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
Dynamic Routing Between Capsules· youtube
Taxonomy
TopicsTopic Modeling · Advanced Neural Network Applications · Advanced Graph Neural Networks
MethodsMICHIGAN +256777182862 Love spells caster, voodoo spells IN MICHIGAN-DETROIT,GRAND RAPIDS · Capsule Network · Capsule Network
Dynamic Routing Between Capsules
Sara Sabour
\AndNicholas Frosst
\ANDGeoffrey E. Hinton
Google Brain
Toronto
{sasabour, frosst, geoffhinton}@google.com
(May 2017)
Abstract
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 an 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 parameters. 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.
1 Introduction
Human vision ignores irrelevant details by using a carefully determined sequence of fixation points to ensure that only a tiny fraction of the optic array is ever processed at the highest resolution. Introspection is a poor guide to understanding how much of our knowledge of a scene comes from the sequence of fixations and how much we glean from a single fixation, but in this paper we will assume that a single fixation gives us much more than just a single identified object and its properties. We assume that our multi-layer visual system creates a parse tree-like structure on each fixation, and we ignore the issue of how these single-fixation parse trees are coordinated over multiple fixations.
Parse trees are generally constructed on the fly by dynamically allocating memory. Following Hinton et al. (2000), however, we shall assume that, for a single fixation, a parse tree is carved out of a fixed multilayer neural network like a sculpture is carved from a rock. Each layer will be divided into many small groups of neurons called “capsules” (Hinton et al. (2011)) and each node in the parse tree will correspond to an active capsule. Using an iterative routing process, each active capsule will choose a capsule in the layer above to be its parent in the tree. For the higher levels of a visual system, this iterative process will be solving the problem of assigning parts to wholes.
The activities of the neurons within an active capsule represent the various properties of a particular entity that is present in the image. These properties can include many different types of instantiation parameter such as pose (position, size, orientation), deformation, velocity, albedo, hue, texture, etc. One very special property is the existence of the instantiated entity in the image. An obvious way to represent existence is by using a separate logistic unit whose output is the probability that the entity exists. In this paper we explore an interesting alternative which is to use the overall length of the vector of instantiation parameters to represent the existence of the entity and to force the orientation of the vector to represent the properties of the entity111This makes biological sense as it does not use large activities to get accurate representations of things that probably don’t exist.. We ensure that the length of the vector output of a capsule cannot exceed by applying a non-linearity that leaves the orientation of the vector unchanged but scales down its magnitude.
The fact that the output of a capsule is a vector makes it possible to use a powerful dynamic routing mechanism to ensure that the output of the capsule gets sent to an appropriate parent in the layer above. Initially, the output is routed to all possible parents but is scaled down by coupling coefficients that sum to . For each possible parent, the capsule computes a “prediction vector” by multiplying its own output by a weight matrix. If this prediction vector has a large scalar product with the output of a possible parent, there is top-down feedback which increases the coupling coefficient for that parent and decreasing it for other parents. This increases the contribution that the capsule makes to that parent thus further increasing the scalar product of the capsule’s prediction with the parent’s output. This type of “routing-by-agreement” should be far more effective than the very primitive form of routing implemented by max-pooling, which allows neurons in one layer to ignore all but the most active feature detector in a local pool in the layer below. We demonstrate that our dynamic routing mechanism is an effective way to implement the “explaining away” that is needed for segmenting highly overlapping objects.
Convolutional neural networks (CNNs) use translated replicas of learned feature detectors. This allows them to translate knowledge about good weight values acquired at one position in an image to other positions. This has proven extremely helpful in image interpretation. Even though we are replacing the scalar-output feature detectors of CNNs with vector-output capsules and max-pooling with routing-by-agreement, we would still like to replicate learned knowledge across space. To achieve this, we make all but the last layer of capsules be convolutional. As with CNNs, we make higher-level capsules cover larger regions of the image. Unlike max-pooling however, we do not throw away information about the precise position of the entity within the region. For low level capsules, location information is “place-coded” by which capsule is active. As we ascend the hierarchy, more and more of the positional information is “rate-coded” in the real-valued components of the output vector of a capsule. This shift from place-coding to rate-coding combined with the fact that higher-level capsules represent more complex entities with more degrees of freedom suggests that the dimensionality of capsules should increase as we ascend the hierarchy.
2 How the vector inputs and outputs of a capsule are computed
There are many possible ways to implement the general idea of capsules. The aim of this paper is not to explore this whole space but simply to show that one fairly straightforward implementation works well and that dynamic routing helps.
We want the length of the output vector of a capsule to represent the probability that the entity represented by the capsule is present in the current input. We therefore use a non-linear "squashing" function to ensure that short vectors get shrunk to almost zero length and long vectors get shrunk to a length slightly below . We leave it to discriminative learning to make good use of this non-linearity.
[TABLE]
where is the vector output of capsule and is its total input.
For all but the first layer of capsules, the total input to a capsule is a weighted sum over all “prediction vectors” from the capsules in the layer below and is produced by multiplying the output of a capsule in the layer below by a weight matrix
[TABLE]
where the are coupling coefficients that are determined by the iterative dynamic routing process.
The coupling coefficients between capsule and all the capsules in the layer above sum to and are determined by a “routing softmax” whose initial logits are the log prior probabilities that capsule should be coupled to capsule .
[TABLE]
The log priors can be learned discriminatively at the same time as all the other weights. They depend on the location and type of the two capsules but not on the current input image222For MNIST we found that it was sufficient to set all of these priors to be equal.. The initial coupling coefficients are then iteratively refined by measuring the agreement between the current output of each capsule, , in the layer above and the prediction made by capsule .
The agreement is simply the scalar product . This agreement is treated as if it was a log likelihood and is added to the initial logit, before computing the new values for all the coupling coefficients linking capsule to higher level capsules.
In convolutional capsule layers, each capsule outputs a local grid of vectors to each type of capsule in the layer above using different transformation matrices for each member of the grid as well as for each type of capsule.
3 Margin loss for digit existence
We are using the length of the instantiation vector to represent the probability that a capsule’s entity exists. We would like the top-level capsule for digit class to have a long instantiation vector if and only if that digit is present in the image. To allow for multiple digits, we use a separate margin loss, for each digit capsule, :
[TABLE]
where iff a digit of class is present333We do not allow an image to contain two instances of the same digit class. We address this weakness of capsules in the discussion section. and and . The down-weighting of the loss for absent digit classes stops the initial learning from shrinking the lengths of the activity vectors of all the digit capsules. We use . The total loss is simply the sum of the losses of all digit capsules.
4 CapsNet architecture
A simple CapsNet architecture is shown in Fig. 1. The architecture is shallow with only two convolutional layers and one fully connected layer. Conv has , convolution kernels with a stride of 1 and ReLU activation. This layer converts pixel intensities to the activities of local feature detectors that are then used as inputs to the primary capsules.
The primary capsules are the lowest level of multi-dimensional entities and, from an inverse graphics perspective, activating the primary capsules corresponds to inverting the rendering process. This is a very different type of computation than piecing instantiated parts together to make familiar wholes, which is what capsules are designed to be good at.
The second layer (PrimaryCapsules) is a convolutional capsule layer with channels of convolutional D capsules (i.e. each primary capsule contains 8 convolutional units with a kernel and a stride of 2). Each primary capsule output sees the outputs of all Conv units whose receptive fields overlap with the location of the center of the capsule. In total PrimaryCapsules has capsule outputs (each output is an D vector) and each capsule in the grid is sharing their weights with each other. One can see PrimaryCapsules as a Convolution layer with Eq. 1 as its block non-linearity. The final Layer (DigitCaps) has one D capsule per digit class and each of these capsules receives input from all the capsules in the layer below.
We have routing only between two consecutive capsule layers (e.g. PrimaryCapsules and DigitCaps). Since Conv output is D, there is no orientation in its space to agree on. Therefore, no routing is used between Conv and PrimaryCapsules. All the routing logits () are initialized to zero. Therefore, initially a capsule output () is sent to all parent capsules () with equal probability ().
Our implementation is in TensorFlow (Abadi et al. (2016)) and we use the Adam optimizer (Kingma and Ba (2014)) with its TensorFlow default parameters, including the exponentially decaying learning rate, to minimize the sum of the margin losses in Eq. 4.
4.1 Reconstruction as a regularization method
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Abadi et al. [2016] Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, et al. Tensorflow: Large-scale machine learning on heterogeneous distributed systems. ar Xiv preprint ar Xiv:1603.04467 , 2016.
- 2Ba et al. [2014] Jimmy Ba, Volodymyr Mnih, and Koray Kavukcuoglu. Multiple object recognition with visual attention. ar Xiv preprint ar Xiv:1412.7755 , 2014.
- 3Chang and Chen [2015] Jia-Ren Chang and Yong-Sheng Chen. Batch-normalized maxout network in network. ar Xiv preprint ar Xiv:1511.02583 , 2015.
- 4Cireşan et al. [2011] Dan C Cireşan, Ueli Meier, Jonathan Masci, Luca M Gambardella, and Jürgen Schmidhuber. High-performance neural networks for visual object classification. ar Xiv preprint ar Xiv:1102.0183 , 2011.
- 5Goodfellow et al. [2013] Ian J Goodfellow, Yaroslav Bulatov, Julian Ibarz, Sacha Arnoud, and Vinay Shet. Multi-digit number recognition from street view imagery using deep convolutional neural networks. ar Xiv preprint ar Xiv:1312.6082 , 2013.
- 6Greff et al. [2016] Klaus Greff, Antti Rasmus, Mathias Berglund, Tele Hao, Harri Valpola, and Jürgen Schmidhuber. Tagger: Deep unsupervised perceptual grouping. In Advances in Neural Information Processing Systems , pages 4484–4492, 2016.
- 7Hinton [1981 a] Geoffrey E Hinton. Shape representation in parallel systems. In International Joint Conference on Artificial Intelligence Vol 2 , 1981 a.
- 8Hinton [1981 b] Geoffrey E Hinton. A parallel computation that assigns canonical object-based frames of reference. In Proceedings of the 7th international joint conference on Artificial intelligence-Volume 2 , pages 683–685. Morgan Kaufmann Publishers Inc., 1981 b.
