Capsule Networks as Generative Models

Alex B. Kiefer, Beren Millidge, Alexander Tschantz, Christopher L. BuckleyIWAI 2022

Abstract

Capsule networks are a neural network architecture specialized for visual scene recognition. Features and pose information are extracted from a scene and then dynamically routed through a hierarchy of vector-valued nodes called 'capsules' to create an implicit scene graph, with the ultimate aim of learning vision directly as inverse graphics. Despite these intuitions, however, capsule networks are not formulated as explicit probabilistic generative models; moreover, the routing algorithms typically used are ad-hoc and primarily motivated by algorithmic intuition. In this paper, we derive an alternative capsule routing algorithm utilizing iterative inference under sparsity constraints. We then introduce an explicit probabilistic generative model for capsule networks based on the self-attention operation in transformer networks and show how it is related to a variant of predictive coding networks using Von-Mises-Fisher (VMF) circular Gaussian distributions.

Introduction

Since their introduction, Capsule Networks (CapsNets) have been celebrated for their "inverse graphics" intuition—the idea that vision should be the process of deconstructing an image into a hierarchical scene graph of parts and wholes. However, while the intuition is top-down (generative), the implementation has remained largely bottom-up and heuristic. The "routing-by-agreement" algorithm, which decides how information flows from lower-level "part" capsules to higher-level "whole" capsules, is often criticized as being ad-hoc. This paper addresses the lack of an explicit probabilistic model describing how a scene generates an image in a CapsNet framework, deriving a generative model that justifies routing operations.

Methods

The proposed framework bridges the gap between heuristic routing and formal probabilistic inference through several key innovations:

  • Von-Mises-Fisher (VMF) Distributions: To handle capsule "pose" (represented as vectors), the authors utilize the VMF distribution, a "circular Gaussian" on a hypersphere. This provides a principled probabilistic language for angular data, which is central to capsule similarity measures like dot products.
  • Generative Self-Attention: Top-down generation of lower-level capsules is framed as a self-attention operation. Here, the "Query" is the lower-level capsule, while "Keys" and "Values" are derived from higher-level capsules.
  • Sparse Iterative Inference: Standard routing is replaced with an iterative inference process derived from Predictive Coding Networks (PCNs). An $L_1$ penalty is added to enforce the "single-parent" constraint, ensuring a part belongs to only one whole.
Figure 1: Architecture of the Capsule Network used for MNIST classification, illustrating the flow from input through convolutional layers to DigitCaps.

Results

Evaluation on the MNIST dataset yielded several key insights:

  • Routing as Inference: Routing is shown to be an approximation of posterior inference, where capsules seek the most likely top-down explanation for bottom-up data.
  • Sparsity via Inference: Iterative inference with an $L_1$ penalty successfully reproduces routing behavior, concentrating probability mass on a single "best" parent capsule.
  • Performance Parity: Surprisingly, CapsNets with zero routing iterations achieved >99% accuracy on MNIST. This suggests that the margin loss function and learned transformation matrices are primary drivers of structure, rather than the routing algorithm itself.
Figure 2: Examples of capsule activations for various MNIST digits. The model successfully concentrates probability mass on the correct digit capsule (highlighted in red).

Discussion

The connection between capsule updates and self-attention suggests a convergence in AI architectures, where capsules can be viewed as a way to implement iterative attention. Furthermore, the reliance on sparse iterative inference aligns with neuroscience observations of sparse cortical connectivity and recurrent projections. Future work includes fully inverting the model using variational inference and scaling the approach to complex natural image datasets like ImageNet.

Summary updated

BibTeX
@inproceedings{kiefer2022capsule,
  author = {Alex B. Kiefer and Beren Millidge and Alexander Tschantz and Christopher L. Buckley},
  title = {{Capsule Networks as Generative Models}},
  booktitle = {IWAI},
  year = {2022},
  url = {https://openreview.net/forum?id=WpcaUypGar},
}
Figure