Back to Projects

Deconstructing CapsNets from Scratch

Explore the mathematics of capsule vectors, dynamic routing, and viewpoint equivariance — built entirely from scratch in pure PyTorch.

Part 1

The Math of Equivariance

Breaking down why pooling loses spatial relationships, capsule pose vectors, the squashing function, and routing-by-agreement.

Part 2

PyTorch Implementation

Building PrimaryCapsules, DigitCapsules, dynamic routing, and a reconstruction decoder — entirely from scratch.
View Code on GitHub

Part 3

Viewpoint Invariance

98.34% MNIST accuracy, reconstruction visualization, and +21% rotation robustness advantage over standard CNNs at 45 degrees.