Hi,
I think the softmax in the routing algorithm is being calculated over the wrong dimension.
Currently the code has:
# Initialize routing logits to zero.
b_ij = Variable(torch.zeros(1, self.in_channels, self.num_units, 1)).cuda()
# Iterative routing.
num_iterations = 3
for iteration in range(num_iterations):
# Convert routing logits to softmax.
# (batch, features, num_units, 1, 1)
c_ij = F.softmax(b_ij)
and since the dim parameter is not passed to the F.softmax call it will choose dim=1 and compute the softmax over the self.in_channels dimension (1152 here) whereas the softmax should be computed so that the c_ij between each input capsule and all the capsules in the next layer should sum to 1.
Thus the correct call should be:
c_ij = F.softmax(b_ij, dim=2)
Hi,
I think the softmax in the routing algorithm is being calculated over the wrong dimension.
Currently the code has:
and since the dim parameter is not passed to the
F.softmaxcall it will choose dim=1 and compute the softmax over theself.in_channelsdimension (1152 here) whereas the softmax should be computed so that the c_ij between each input capsule and all the capsules in the next layer should sum to 1.Thus the correct call should be: