PyTorch implementation of Capsules Network, an idea from the NIPS 2017 paper Dynamic Routing Between Capsules.
Here we only discuss the calculation process between the primary capsule layer and dense capsule layer.
For example, we get
Then we need to affine transform the data. For one feature vector, we already the vector's shape is
Now we have ten features, which come from the input feature matrix, to derive a category. But we have five categories, thus we need to make
In order to implement the dynamic routing algorithm, we will initialize a matrix with shape