Title: CAPSULES WITH INVERTED DOT-PRODUCT ATTENTION ROUTING

Abstract: We introduce a new routing algorithm for capsule networks, in which a child capsule is routed to a parent based only on agreement between the parent's state and the child's vote. The new mechanism 1) designs routing via inverted dot-product attention; 2) imposes Layer Normalization as normalization; and 3) replaces sequential iterative routing with concurrent iterative routing. When compared to previously proposed routing algorithms, our method improves performance on benchmark datasets such as CIFAR-10 and CIFAR-100, and it performs at-par with a powerful CNN (ResNet-18) with 4× fewer parameters. On a different task of recognizing digits from overlayed digit images, the proposed capsule model performs favorably against CNNs given the same number of layers and neurons per layer. We believe that our work raises the possibility of applying capsule networks to complex real-world tasks. Our code is publicly available at:

1. INTRODUCTION:

Capsule Networks (CapsNets) represent visual features using groups of neurons. Each group (called a "capsule") encodes a feature and represents one visual entity. Grouping all the information about one entity into one computational unit makes it easy to incorporate priors such as "a part can belong to only one whole" by routing the entire part capsule to its parent whole capsule. Routing is mutually exclusive among parents, which ensures that one part cannot belong to multiple parents. Therefore, capsule routing has the potential to produce an interpretable hierarchical parsing of a visual scene. Such a structure is hard to impose in a typical convolutional neural network (CNN). This hierarchical relationship modeling has spurred a lot of interest in designing capsules and their routing algorithms (Sabour et al., 2017; Hinton et al., 2018; Wang & Liu, 2018; Zhang et al., 2018; Li et al., 2018; Rajasegaran et al., 2019; Kosiorek et al., 2019) .

In order to do routing, each lower-level capsule votes for the state of each higher-level capsule. The higher-level (parent) capsule aggregates the votes, updates its state, and uses the updated state to explain each lower-level capsule. The ones that are well-explained end up routing more towards that parent. This process is repeated, with the vote aggregation step taking into account the extent to which a part is routed to that parent. Therefore, the states of the hidden units and the routing probabilities are inferred in an iterative way, analogous to the M-step and E-step, respectively, of an Expectation-Maximization (EM) algorithm. Dynamic Routing (Sabour et al., 2017) and EMrouting (Hinton et al., 2018) can both be seen as variants of this scheme that share the basic iterative structure but differ in terms of details, such as their capsule design, how the votes are aggregated, and whether a non-linearity is used.

We introduce a novel routing algorithm, which we called Inverted Dot-Product Attention Routing. In our method, the routing procedure resembles an inverted attention mechanism, where dot products are used to measure agreement. Specifically, the higher-level (parent) units compete for the attention of the lower-level (child) units, instead of the other way around, which is commonly used in attention Figure 1 : Illustration of a Capsule network with a backbone block, 3 convolutional capsule layers, 2 fullyconnected capsule layers, and a classifier. The first convolutional capsule layer is called the primary capsule layer. The last fully-connected capsule layer is called the class capsule layer. models. Hence, the routing probability directly depends on the agreement between the parent's pose (from the previous iteration step) and the child's vote for the parent's pose (in the current iteration step). We also propose two modifications for our routing procedure -(1) using Layer Normalization (Ba et al., 2016) as normalization, and (2) doing inference of the latent capsule states and routing probabilities jointly across multiple capsule layers (instead of doing it layer-wise). These modifications help scale up the model to more challenging datasets.

Our model achieves comparable performance as the state-of-the-art convolutional neural networks (CNNs), but with much fewer parameters, on CIFAR-10 (95.14% test accuracy) and CIFAR-100 (78.02% test accuracy). We also introduce a challenging task to recognize single and multiple overlapping objects simultaneously. To be more precise, we construct the DiverseMultiMNIST dataset that contains both single-digit and overlapping-digits images. With the same number of layers and the same number of neurons per layer, the proposed CapsNet has better convergence than a baseline CNN. Overall, we argue that with the proposed routing mechanism, it is no longer impractical to apply CapsNets on real-world tasks. We will release the source code to reproduce the experiments.

2. CAPSULE NETWORK ARCHITECTURE:

An example of our proposed architecture is shown in Figure 1 . The backbone is a standard feedforward convolutional neural network. The features extracted from this network are fed through another convolutional layer. At each spatial location, groups of 16 channels are made to create capsules (we assume a 16-dimensional pose in a capsule). LayerNorm is then applied across the 16 channels to obtain the primary capsules. This is followed by two convolutional capsule layers, and then by two fully-connected capsule layers. In the last capsule layer, each capsule corresponds to a class. These capsules are then used to compute logits that feed into a softmax to computed the classification probabilities. Inference in this network requires a feed-forward pass up to the primary capsules. After this, our proposed routing mechanism (discussed in the next section) takes over.

In prior work, each capsule has a pose and some way of representing an activation probability. In Dynamic Routing CapsNets (Sabour et al., 2017) , the pose is represented by a vector and the activation probability is implicitly represented by the norm of the pose. In EM Routing CapsNets (Hinton et al., 2018) , the pose is represented by a matrix and the activation probability is determined by the EM algorithm. In our work, we consider a matrix-structured pose in a capsule. We denote the capsules in layer L as P L and the i-th capsule in layer L as p L i . The pose p L i ∈ R d L in a vector form and will be reshaped to R

√ d L × √

d L when representing it as a matrix, where d L is the number of hidden units grouped together to make capsules in layer L. The activation probability is not explicitly represented. By doing this, we are essentially asking the network to represent the absence of a capsule by some special value of its pose.

3. INVERTED DOT-PRODUCT ATTENTION ROUTING:

The proposed routing process consists of two steps. The first step computes the agreement between lower-level capsules and higher-level capsules. The second step updates the pose of the higher-level capsules.

Step 1: Computing Agreement: To determine how capsule j in layer L + 1 (p L+1 for all capsule i in layer L and capsule j in layer (L + 1):

v L ij ← W L ij • p L i vote 3:

for all capsule i in layer L and capsule j in layer (L + 1):

a L ij ← p L+1 j • v L ij agreement 4:

for all capsule i in layer

L: r L ij ← exp(a L ij ) / j exp(a L ij ) routing coefficient 5:

for all capsule j in layer (L + 1):

p L+1 j ← i r L ij v L ij pose update 6:

for all capsule j in layer (L + 1):

p L+1 j ← LayerNorm(p L+1 j ) normalization 7: return P L+1

transformation is done using a learned transformation matrix W L ij :

EQUATION

where the matrix W L ij ∈ R d L+1 ×d L if the pose has a vector structure and

W L ij ∈ R √ d L+1 × √ d L (requires d L+1 = d L )

if the pose has a matrix structure. Next, the agreement (a L ij ) is computed by the dot-product similarity between a pose p L+1 j and a vote v L ij :

EQUATION

The pose p L+1 j is obtained from the previous iteration of this procedure, and will be set to 0 initially.

Step 2: Computing Poses: The agreement scores a L ij are passed through a softmax function to determine the routing probabilities r L ij :

EQUATION

where r L ij is an inverted attention score representing how higher-level capsules compete for attention of lower-level capsules. Using the routing probabilities, we update the pose p L+1 j for capsule j in layer L + 1 from all capsules in layer L:

EQUATION

We adopt Layer Normalization (Ba et al., 2016) as the normalization, which we empirically find it to be able to improve the convergence for routing. The routing algorithm is summarized in Procedure 1 and Figure 2 .

4. INFERENCE AND LEARNING:

To explain how inference and learning are performed, we use Figure 1 as an example. Note that the choice of the backbone, the number of capsules layers, the number of capsules per layer, the design of the classifier may vary for different sets of experiments. We leave the discussions of configurations in Sections 5 and 6, and in the Appendix.

Procedure 2 Inference. Inference returns class logits given input images and parameters for the model. Capsule layer 1 denotes the primary capsules layer and layer N denotes the class capsules layer. return ŷ

4.1. INFERENCE:

For ease of exposition, we decompose a CapsNet into pre-capsule, capsule and post-capsule layers.

Pre-Capsule Layers: The goal is to obtain a backbone feature F from the input image I. The backbone model can be either a single convolutional layer or ResNet computational blocks (He et al., 2016) .

Capsule Layers: The primary capsules P1 are computed by applying a convolution layer and Layer Normalization to the backbone feature F. The non-primary capsules layers P 2:N are initialized to be zeros 1 . For the first iteration, we perform one step of routing sequentially in each capsule layer. In other words, the primary capsules are used to update their parent convolutional capsules, which are then used to update the next higher-level capsule layer, and so on. After doing this first pass, the rest of the routing iterations are performed concurrently. Specifically, all capsule layers look at their preceding lower-level capsule layer and perform one step of routing simultaneously. This procedure is an example of a parallel-in-time inference method. We call it "concurrent routing" as it concurrently performs routing between capsules layers per iteration, leading to better parallelism. Figure 3 illustrates this procedure from routing iteration 2 to t. It is worth noting that, our proposed variant of CapsNet is a weight-tied concurrent routing architecture with Layer Normalization, which Bai et al. ( 2019) empirically showed could converge to fixed points.

Previous CapsNets (Sabour et al., 2017; Hinton et al., 2018) used sequential layer-wise iterative routing between the capsules layers. For example, the model first performs routing between layer L -1 and layer L for a few iterations. Next, the model performs routing between layer L and L + 1 for a few iterations. When unrolled, this sequential iterative routing defines a very deep computational graph with a single path going from the inputs to the outputs. This deep graph could lead to a vanishing gradients problem and limit the depth of a CapsNet that can be trained well, especially if any squashing non-linearities are present. With concurrent routing, the training can be made more stable, since each iteration has a more cumulative effect.

Post-Capsule Layers: The goal is to obtain the predicted class logits ŷ from the last capsule layer (the class capsules) P N . In our CapsNet, we use a linear classifier for class i in class capsules: ŷi = classifier(p N i ). This classifier is shared across all the class capsules. The concurrent routing is a parallel-in-time routing procedure for all capsules layers. 

4.2. LEARNING:

We update the parameters θ, W 1:N -1 by stochastic gradient descent. For multiclass classification, we use multiclass cross-entropy loss. For multilabel classification, we use binary cross-entropy loss.

We also tried Margin loss and Spread loss which are introduced by prior work (Sabour et al., 2017; Hinton et al., 2018) . However, these losses do not give us better performance against cross-entropy and binary cross-entropy losses.

4.3. COMPARISONS WITH EXISTING CAPSNET MODELS:

Having described our model in detail, we can now place the model in the context of previous work.

In the following table, we list the major differences among different variants of CapsNets.

Dynamic Routing (Sabour et al., 2017) EM Routing (Hinton et Comparisons with other CapsNets and CNNs: In Table 1 , we report the test accuracy obtained by our model, along with other CapsNets and CNNs. Two prior CapsNets are chosen: Dynamic Routing CapsNets (Sabour et al., 2017) and EM Routing CapsNets (Hinton et al., 2018) . For each CapsNet, we apply two backbone feature models: simple convolution followed by ReLU nonlinear activation and a ResNet (He et al., 2016) backbone. For CNNs, we consider a baseline CNN with 3 convolutional layers followed by 1 fully-connected classifier layer. ResNet-18 is selected as a representative of SOTA CNNs. See Appendix A.1 for detailed configurations.

First, we compare previous routing approaches against ours. In a general trend, the proposed Cap-sNets perform better than the Dynamic Routing CapsNets, and the Dynamic Routing CapsNets perform better than EM Routing CapsNets. The performance differs more on CIFAR-100 than on CIFAR-10. Second, we discuss the performance difference between CNNs and CapsNets. We see that, with a simple backbone (a single convolutional layer), it is hard for CapsNets to reach the same performance as CNNs. For instance, our routing approach can only achieve 57.32% test accuracy on CIFAR-100 while the baseline CNN achieves 62.30%. However, with a SOTA backbone structure (ResNet backbone), the proposed routing approach can reach competitive performance (95.14% on CIFAR-10) as compared to the SOTA CNN model (ResNet-18 with 95.11% on CIFAR-10).

Convergence Analysis: In Figure 4 , top row, we analyze the convergence for CapsNets with respect to the number of routing iterations. The optimization hyperparameters are chosen optimally for each routing mechanism. For Dynamic Routing CapsNets (Sabour et al., 2017) , we observe a mild performance drop when the number of iterations increases. For EM Routing CapsNets (Hinton et al., 2018) , the best-performed number of iterations is 2. Increasing or decreasing this number severely hurts the performance. For our proposed routing mechanism, we find a positive correlation between performance and number of routing iterations. The performance variance is also the smallest among We consider the same optimizer, the same number of layers, and the same number of neurons per layer for the models. For fairness, memory usage/ inference time are benchmarked using the same 8-GPU machine with batch size 128. CapsNet * denotes the Dynamic routing method and CapsNet denotes our proposed Inverted Dot-Product Attention Routing method. Note that for future comparisons, we refer the readers to an alternative implementation for our model: https://github.com/yaohungt/ Capsules-Inverted-Attention-Routing/blob/master/README.md. It uses much less memory, has a significantly faster inference speed, and retains the same performance. The memory usage and inference time in this implementation now are only marginally higher than the baseline CNN.

the three routing mechanisms. This result suggests our approach has better optimization and stable inference. However, selecting a larger iteration number may not be ideal since memory usage and inference time will also increase (shown in the bottom right in Figure 4 ). Note that, we observe sharp performance jitters during training when the model has not converged (especially when the number of iterations is high). This phenomenon is due to applying LayerNorm on a low-dimensional vector.

The jittering is reduced when we increase the pose dimension in capsules.

Ablation Study: Furthermore, we inspect our routing approach with the following ablations: 1) Inverted Dot-Product Attention-A: without Layer Normalization; 2) Inverted Dot-Product Attention-B: replacing concurrent to sequential iterative routing; and 3) Inverted Dot-Product Attention-C: adding activations in capsules2 . The results are presented in Figure 4 bottom row. When removing Layer Normalization, performance dramatically drops from our routing mechanism. Notably, the prediction becomes uniform when the iteration number increases to 5. This result implies that the normalization step is crucial to the stability of our method. When replacing concurrent with sequential iterative routing, the positive correlation between performance and iteration number no longer exists. This fact happens in the Dynamic Routing CapsNet as well, which also uses sequential iterative routing. When adding activations to our capsule design, we obtain a performance deterioration. Typically, squashing activations such as sigmoids make it harder for gradients to flow, which might explain this. Discovering the best strategy to incorporate activations in capsule networks is an interesting direction for future work.

6. EXPERIMENTS ON DIVERSEMULTIMNIST:

The goal in this section is to compare CapsNets and CNNs when they have the same number of layers and the same number of neurons per layer. Specifically, we would like to examine the difference of the representation power between the routing mechanism (in CapsNets) and the pooling operation (in CNNs). A challenging setting is considered in which objects may be overlapping with each other, and there may be a diverse number of objects in the image. To this end, we construct the DiverseMultiMNIST dataset which is extended from MNIST (LeCun et al., 1998) , and it contains both single-digit and two overlapping digit images. The task will be multilabel classification, where the prediction is said to be correct if and only if the recognized digits match all the digits in the image. We plot the convergence curve when the model is trained on 21M images from DiverseMul-tiMNIST. Please see Appendix B.2 for more details on the dataset and Appendix B.1 for detailed model configurations. The results are reported in Figure 5 .

First, we compare our routing method against the Dynamic routing one. We observe an improved performance from the CapsNet * to the CapsNet (83.39% to 85.74% with vector-structured poses).

The result suggests a better viewpoint generalization for our routing mechanism.

Second, we compare baseline CNN against our CapsNet. From the table, we see that CapsNet has better test accuracy compared to CNN. For example, the CapsNet with vector-structured poses reaches 85.74% test accuracy, and the baseline CNN reaches 79.81% test accuracy. In our CNN implementation, we use average pooling from the last convolutional layer to its next fully-connected layer. We can see that having a routing mechanism works better than pooling. However, one may argue that the pooling operations requires no extra parameter but routing mechanism does, and hence it may not be fair to compare their performance. To address this issue, in the baseline CNN, we replace the pooling operation with a fully-connected operation. To be more precise, instead of using average pooling, we learn the entire transformation matrix from the last convolutional layer to its next fully-connected layer. This procedure can be regarded as considering pooling with learnable parameters. After doing this, the number of parameters in CNN increases to 42.49M , and the corresponding test accuracy is 84.84%, which is still lower than 85.74% from the CapsNet. We conclude that, when recognizing overlapping and diverse number of objects, the routing mechanism has better representation power against the pooling operation.

Last, we compare CapsNet with different pose structures. The CapsNet with vector-structured poses works better than the CapsNet with matrix-structured poses (80.59% vs 85.74%). However, the former requires more parameters, more memory usage, and more inference time. If we increase the number of parameters in the matrix-pose CapsNet to 42M , its test accuracy rises to 91.17%.

Nevertheless, the model now requires more memory usage and inference time as compared to using vector-structured poses. We conclude that more performance can be extracted from vector-structured poses but at the cost of high memory usage and inference time.

7. RELATED WORK:

The idea of grouping a set of neurons into a capsule was first proposed in Transforming Auto-Encoders (Hinton et al., 2011) . The capsule represented the multi-scale recognized fragments of the input images. Given the transformation matrix, Transforming Auto-Encoders learned to discover capsules' instantiation parameters from an affine-transformed image pair. Sabour et al. (2017) extended this idea to learn part-whole relationships in images systematically. Hinton et al. (2018) cast the routing mechanism as fitting a mixture of Gaussians. The model demonstrated an impressive ability for recognizing objects from novel viewpoints. Recently, Stacked Capsule Auto-Encoders (Kosiorek et al., 2019) proposed to segment and compose the image fragments without any supervision. The work achieved SOTA results on unsupervised classification. However, despite showing promising applications by leveraging inherent structures in images, the current literature on capsule networks has only been applied on datasets of limited complexity. Our proposed new routing mechanism instead attempts to apply capsule networks to more complex data.

Our model also relates to Transformers (Vaswani et al., 2017) and Set Transformers (Lee et al., 2019) , where dot-product attention is also used. In the language of capsules, a Set Transformer can be seen as a model in which a higher-level unit can choose to pay attention to K lower-level units (using K attention heads). Our model inverts the attention direction (lower-level units "attend" to parents), enforces exclusivity among routing to parents and does not impose any limits on how many lower-level units can be routed to any parent. Therefore, it combines the ease and parallelism of dot-product routing derived from a Transformer, with the interpretability of building a hierarchical parsing of a scene derived from capsule networks.

There are other works presenting different routing mechanisms for capsules. Wang & Liu (2018) formulated the Dynamic routing (Sabour et al., 2017) as an optimization problem consisting of a clustering loss and a KL regularization term. Zhang et al. (2018) generalized the routing method within the framework of weighted kernel density estimation. Li et al. (2018) 

B.2 DATASET CONSTRUCTION:

Diverse MultiMNIST contains both single-digit and overlapping-digit images. We generate images on the fly and plot the test accuracy for training models over 21M (21M = 350(steps) × 60, 000(images)) generated images. We also generate the test images, and for each evaluation step, there are 10, 000 test images. Note that we make sure the training and the test images are from the disjoint set. In the following, we shall present how we generate the images. We set the probability of generating a single-digit image as 1 6 and the probability of generating an overlapping-digit image as 5

6 . The single-digit image in DiverseMultiMNIST training/ test set is generated by shifting digits in MNIST (LeCun et al., 1998) training/ test set. Each digit is shifted up to 4 pixels in each direction and results in 36 × 36 image.

Following Sabour et al. (2017) , we generate overlapping-digit images in DiverseMultiMNIST training/ test set by overlaying two digits from the same training/ test set of MNIST. Two digits are selected from different classes. Before overlaying the digits, we shift the digits in the same way which we shift for the digit in a single-digit image. After overlapping, the generated image has size 36 × 36.

We consider no data augmentation for both training and evaluation. All the model is trained on a 8-GPU machine with batch size 128. 

:

As compared to 0 initialization, we observe that a random initialization leads to similar converged performance but slower convergence speed. We also tried to learn biases for capsules' initialization, which results in similar converged performance and same convergence speed. As a summary, we initialize the capsule's value to 0 for simplicity.

We consider the same kind of capsules activations as described in EM Routing CapsNets(Hinton et al., 2018).

Figures and Tables:

Figure 2: Illustration of the Inverted Dot-Product Attention Routing with the pose admitting matrix structure.

procedure INFERENCE(I; θ, W 1:N -1 ) /* Pre-Capsules Layers: backbone features extraction */ layers 2 to N : P L ← 0s non-primary capsules /* Capsules Layers (1st Iteration): sequential routing */ 5: for L in layers 1 to (N -1) do 6: P L+1 ← Routing (P L , P L+1 ; W L ) non-primary capsules /* Capsules Layers (2nd to tth Iteration): concurrent routing */ 7: for (t -1) iterations do 8: for L in layers 1 to (N -1): PL+1 ← Routing (P L , P L+1 ; W L ) 9: for L in layers 2 to N : P L ← PL non-primary capsules /* Post-Capsules Layers: classification */ 10: for all capsule i in layer N : ŷi ← classifier(p N i ; θ) class logits 11:

Figure 3: Illustration of the proposed concurrent routing from iteration 2 to t with the example in Figure 1.

Figure 4: Convergence analysis for CapsNets on CIFAR-10 with simple backbone model. Top: convergence plots for different routing mechanisms. Bottom left: classification results with respect to different routing iterations.Inverted Dot-Product Attention-A denotes our routing approach without Layer Normalization. Inverted Dot-Product Attention-B denotes our routing approach with sequential routing. Inverted Dot-Product Attention-C denotes our routing approach with activations in capsules. * indicates a uniform prediction. Bottom right: memory usage and inference time for the proposed Inverted Dot-Product Attention Routing. For fairness, the numbers are benchmarked using the same 8-GPU machine with batch size 128. Note that for future comparisons, we refer the readers to an alternative implementation for our model: https://github. com/yaohungt/Capsules-Inverted-Attention-Routing/blob/master/README.md. It uses much less memory, has a significantly faster inference speed, and retains the same performance.

Classification results on CIFAR-10/CIFAR-100 without ensembling models. We report the best performance for CapsNets when considering 1 to 5 routing iterations. We report the performance from the best test model for baseline routing methods, our routing method, and ResNet(He et al., 2016).

Table content: <table><tr><td>Method</td><td>Backbone</td><td colspan="2">Test Accuracy (# of parameters)</td></tr><tr><td/><td/><td>CIFAR-10</td><td>CIFAR-100</td></tr><tr><td>Dynamic Routing (Sabour et al., 2017)</td><td>simple</td><td colspan="2">84.08% (7.99M) 56.96% (31.59M)</td></tr><tr><td>EM Routing (Hinton et al., 2018)</td><td>simple</td><td>82.19 (0.45M)</td><td>37.73% (0.50M)</td></tr><tr><td>Inverted Dot-Product Attention Routing (ours)</td><td>simple</td><td>85.17 (0.56M)</td><td>57.32% (1.46M)</td></tr><tr><td>Dynamic Routing (Sabour et al., 2017)</td><td>ResNet</td><td colspan="2">92.65% (12.45M) 71.70% (36.04M)</td></tr><tr><td>EM Routing (Hinton et al., 2018)</td><td>ResNet</td><td>92.15% (1.71M)</td><td>58.08% (1.76M)</td></tr><tr><td>Inverted Dot-Product Attention Routing (ours)</td><td>ResNet</td><td>95.14% (1.83M)</td><td>78.02% (2.80M)</td></tr><tr><td>Baseline CNN (simple)</td><td/><td colspan="2">87.10% (18.92M) 62.30% (19.01M)</td></tr><tr><td>ResNet-18 (He et al., 2016)</td><td/><td colspan="2">95.11% (11.17M) 77.92% (11.22M)</td></tr></table>

Product Attention-A 66.83% 65.83% 66.22% 77.03% 10.00% * 23.96% Inverted Dot-Product Attention-B 84.24% 83.35% 80.21% 83.37% 82.07% 1.40% Inverted Dot-Product Attention-C 82.55% 83.12% 82.13% 82.38% 81.97%

Table content: <table><tr><td colspan="2">Routing Method</td><td colspan="5">Test Accuracy for Various Routing Iterations</td></tr><tr><td/><td/><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>std</td></tr><tr><td colspan="2">Dynamic (Sabour et al., 2017)</td><td colspan="5">84.08% 83.30% 82.88% 82.90% 82.11%</td><td>0.64%</td></tr><tr><td colspan="2">EM (Hinton et al., 2018)</td><td colspan="5">58.08% 82.19% 78.43% 46.13% 31.41% 19.20%</td></tr><tr><td colspan="7">Inverted Dot-0.40%</td></tr><tr><td colspan="2">Inverted Dot-Product Attention</td><td colspan="5">84.24% 85.05% 84.83% 85.17% 85.09%</td><td>0.34%</td></tr><tr><td/><td/><td/><td/><td/><td/><td>Inverted Dot-Product Attention Routing</td></tr><tr><td/><td/><td/><td/><td/><td/><td>al., 2018)</td><td>(ours)</td></tr><tr><td>Routing</td><td colspan="6">sequential iterative routing sequential iterative routing</td><td>concurrent iterative routing</td></tr><tr><td>Poses</td><td/><td>vector</td><td/><td/><td/><td>matrix</td><td>matrix</td></tr><tr><td>Activations</td><td colspan="3">n/a (norm of poses)</td><td/><td colspan="2">determined by EM</td><td>n/a</td></tr><tr><td>Non-linearity</td><td colspan="3">Squash function</td><td/><td/><td>n/a</td><td>n/a</td></tr><tr><td>Normalization</td><td/><td>n/a</td><td/><td/><td/><td>n/a</td><td>Layer Normalization</td></tr><tr><td>Loss Function</td><td/><td>Margin loss</td><td/><td/><td/><td>Spread loss</td><td>Cross Entropy/Binary Cross Entropy</td></tr><tr><td colspan="7">5 EXPERIMENTS ON CIFAR-10 AND CIFAR-100</td></tr></table>

To conclude, combining the proposed Inverted Dot-Product Attention Routing with ResNet backbone gives us both the advantages of a low number of parameters and high performance.

Table content: <table/>

Figure 5:Table and convergence plot for baseline CNN and CapsNets with different pose structures.

Table content: <table><tr><td/><td/><td/><td/><td colspan="2">Baseline CNN</td><td/></tr><tr><td>Method</td><td colspan="3">Pose Structure Test Acc. # params.</td><td colspan="3">CapsNet (Vector; 2 routing iterations) CapsNet (Matrix; 2 routing iterations)</td></tr><tr><td>CapsNet  *</td><td>vector</td><td>83.39%</td><td>42.48M</td><td>8</td><td>170</td><td>130</td></tr><tr><td>CapsNet</td><td>matrix</td><td>80.59%</td><td>9.96M</td><td>6</td><td>127.5</td><td>97.5</td></tr><tr><td>CapsNet</td><td>vector</td><td>85.74%</td><td>42.48M</td><td>4</td><td>85</td><td>65</td></tr><tr><td colspan="2">Baseline CNN</td><td>79.81%</td><td>19.55M</td><td>2</td><td>42.5</td><td>32.5</td></tr><tr><td/><td/><td/><td/><td>0</td><td>0</td><td>0</td></tr><tr><td/><td/><td/><td/><td>Memory (GB)</td><td>Training Time (ms)</td><td>Evaluation Time (ms)</td></tr></table>

approximated the routing process with two branches and minimized the distributions between capsules layers by an optimal transport divergence constraint. Phaye et al. (2018) replaced standard convolutional structures before capsules layers by densely connected convolutions. It is worth noting that this work was the first to combine SOTA CNN backbones with capsules layers.Rajasegaran et al. (2019) proposed DeepCaps by stacking 10+ capsules layers. It achieved 92.74% test accuracy on CIFAR-10, which was the previous best for capsule networks. Instead of looking for agreement between cap-

Table content: <table/>

Baseline CNN for CIFAR-10.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=1024, 3x3 conv, stride=2, padding=1 ReLU</td><td>16x16x1024</td></tr><tr><td>input dim=1024, output dim=1024, 3x3 conv, stride=2, padding=1 ReLU + Batch Norm</td><td>8x8x1024</td></tr><tr><td>2x2 average pooling, padding=0</td><td>4x4x1024</td></tr><tr><td>input dim=1024, output dim=1024, 3x3 conv, stride=2, padding=1 ReLU + Batch Norm</td><td>2x2x1024</td></tr><tr><td>2x2 average pooling, padding=0</td><td>1x1x1024</td></tr><tr><td>Flatten</td><td>1024</td></tr><tr><td>input dim=1024, output dim=10, linear</td><td>10</td></tr></table>

Baseline CNN for CIFAR-100.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=1024, 3x3 conv, stride=2, padding=1 ReLU</td><td>16x16x1024</td></tr><tr><td>input dim=1024, output dim=1024, 3x3 conv, stride=2, padding=1 ReLU + Batch Norm</td><td>8x8x1024</td></tr><tr><td>2x2 average pooling, padding=0</td><td>4x4x1024</td></tr><tr><td>input dim=1024, output dim=1024, 3x3 conv, stride=2, padding=1 ReLU + Batch Norm</td><td>2x2x1024</td></tr><tr><td>2x2 average pooling, padding=0</td><td>1x1x1024</td></tr><tr><td>Flatten</td><td>1024</td></tr><tr><td>input dim=1024, output dim=100, linear</td><td>100</td></tr></table>

Dynamic Routing with Simple Backbone for CIFAR-10.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=256, 9x9 conv, stride=1, padding=0 ReLU</td><td>24x24x256</td></tr><tr><td>input dim=256, output dim=256, 9x9 conv, stride=2, padding=0</td><td>8x8x256</td></tr><tr><td>Capsules reshape Squash</td><td>8x8x32x8</td></tr><tr><td>Capsules flatten</td><td>2048x8</td></tr><tr><td>Linear Dynamic Routing to 10 16-dim. capsules Squash</td><td>10x16</td></tr></table>

Dynamic Routing with Simple Backbone for CIFAR-100.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=256, 9x9 conv, stride=1, padding=0 ReLU</td><td>24x24x256</td></tr><tr><td>input dim=256, output dim=256, 9x9 conv, stride=2, padding=0</td><td>8x8x256</td></tr><tr><td>Capsules reshape Squash</td><td>8x8x32x8</td></tr><tr><td>Capsules flatten</td><td>2048x8</td></tr><tr><td>Linear Dynamic Routing to 100 16-dim. capsules Squash</td><td>100x16</td></tr></table>

EM Routing with Simple Backbone for CIFAR-10.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=256, 4x4 conv, stride=2, padding=1 Batch Norm + ReLU</td><td>16x16x256</td></tr><tr><td>input dim=256, output dim=512, 1x1 conv, stride=1, padding=0 &amp; input dim=256, output dim=32, 1x1 conv, stride=1, padding=0 Sigmoid</td><td>16x16x512 &amp; 16x16x32</td></tr><tr><td/><td>16x16x32x4x4</td></tr><tr><td>Capsules reshape (only for poses)</td><td>&amp;</td></tr><tr><td/><td>16x16x32</td></tr><tr><td/><td>7x7x32x4x4</td></tr><tr><td>Conv EM Routing to 32 4x4-dim. capsules, 3x3 conv, stride=2</td><td>&amp;</td></tr><tr><td/><td>7x7x32</td></tr><tr><td/><td>5x5x32x4x4</td></tr><tr><td>Conv EM Routing to 32 4x4-dim. capsules, 3x3 conv, stride=1</td><td>&amp;</td></tr><tr><td/><td>5x5x32</td></tr><tr><td/><td>800x4x4</td></tr><tr><td>Capsules flatten</td><td>&amp;</td></tr><tr><td/><td>800</td></tr><tr><td/><td>10x4x4</td></tr><tr><td>Linear EM Routing to 10 4x4-dim. capsules</td><td>&amp;</td></tr><tr><td/><td>10</td></tr></table>

EM Routing with Simple Backbone for CIFAR-100.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=256, 4x4 conv, stride=2, padding=1 Batch Norm + ReLU</td><td>16x16x256</td></tr><tr><td>input dim=256, output dim=512, 1x1 conv, stride=1, padding=0 &amp; input dim=256, output dim=32, 1x1 conv, stride=1, padding=0 Sigmoid</td><td>16x16x512 &amp; 16x16x32</td></tr><tr><td/><td>16x16x32x4x4</td></tr><tr><td>Capsules reshape (only for poses)</td><td>&amp;</td></tr><tr><td/><td>16x16x32</td></tr><tr><td/><td>7x7x32x4x4</td></tr><tr><td>Conv EM Routing to 32 4x4-dim. capsules, 3x3 conv, stride=2</td><td>&amp;</td></tr><tr><td/><td>7x7x32</td></tr><tr><td/><td>5x5x32x4x4</td></tr><tr><td>Conv EM Routing to 32 4x4-dim. capsules, 3x3 conv, stride=1</td><td>&amp;</td></tr><tr><td/><td>5x5x32</td></tr><tr><td/><td>800x4x4</td></tr><tr><td>Capsules flatten</td><td>&amp;</td></tr><tr><td/><td>800</td></tr><tr><td/><td>100x4x4</td></tr><tr><td>Linear EM Routing to 100 4x4-dim. capsules</td><td>&amp;</td></tr><tr><td/><td>100</td></tr></table>

Proposed Inverted Dot-Product Attention Routing with Simple Backbone for CIFAR-10.

Table content: <table><tr><td>Operation</td><td>Output Size</td></tr><tr><td>input dim=3, output dim=256, 3x3 conv, stride=2, padding=1 ReLU</td><td>16x16x256</td></tr><tr><td>input dim=256, output dim=512, 1x1 conv, stride=1, padding=0 Layer Norm</td><td>16x16x512</td></tr><tr><td>Capsules reshape</td><td>16x16x32x4x4</td></tr><tr><td>Conv Inverted Dot-Product Attention Routing to 32 4x4-dim. capsules, 3x3 conv, stride=2 Layer Norm</td><td>7x7x32x4x4</td></tr><tr><td>Conv Inverted Dot-Product Attention Routing to 32 4x4-dim. capsules, 3x3 conv, stride=1 Layer Norm</td><td>5x5x32x4x4</td></tr><tr><td>Capsules flatten</td><td>800x4x4</td></tr><tr><td>Linear Inverted Dot-Product Attention Routing to 10 4x4-dim. capsules Layer Norm</td><td>10x4x4</td></tr><tr><td>Reshape</td><td>10x16</td></tr><tr><td>input dim=16, output dim=1, linear</td><td>10x1</td></tr><tr><td>Reshape</td><td>10</td></tr></table>

Peer review (iclr2020):
This paper presents a new simpler routing mechanism for capsule networks and achieves good performance on real world data sets making use of this new capsule structure along with a restnet backbone. Strong performance on the cifar10 and cifar100 datasets are presented and the network outperforms earlier versions of capsule networks. This new structure also performs well on an augmented MNIST dataset of overlapping digits (similar to the one used by Sabour et al 2017). Overall the paper is well written and presents solid results. The paper also presents a thorough comparison of two earlier versions of capsules which is a worthwhile contribution in its own right. The paper could be improved by clearing up a few ambiguities: - is the learning rate schedule the same for all three models? in figure 4 it looks like the learning rate is decayed at two distinct points for your model, but only one distinct point for both the EM and Dynamic routing models. -*Notably, the prediction becomes random guess when the iteration number increases to 5.* this sentence is a little confusing. Do you mean when the iteration number the performance is equivalent to not random assignments? - This new algorithm requires that the capsules in L+1 have initialized poses with which to compare agreement between the poses in L. This is initial value seems like it may greatly effect the performance of the model. In the paper it is set to 0 and not expanded upon. It would be interesting to see if randomizing this value, or learning a bias for it would effect performance. -unlike the two previous versions of capsules, the inverted dot product capsules show in figure 4 sudden huge decreases in test accuracy while training. These moments seem to be overcome quite quickly and the model ends up outperforming the other two. But it would be worth mentioning this behavior and perhaps attempting to explain it.