XifengGuo / CapsNet-Pytorch

Pytorch implementation for NIPS2017 paper `Dynamic Routing Between Capsules`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Construction of PrimaryCaps

manuelsh opened this issue · comments

I believe this line:

outputs = outputs.view(x.size(0), -1, self.dim_caps)

is not making the capsules in the right way. In theory if we do:

outputs = self.conv2d(x) outputs_2 = outputs.view(x.size(0), -1, self.dim_caps)

then outputs[0,0:8,0,0] should be equal to outputs_2[0,0,0:8]

and if you apply the view in that way this may not be guaranteed.

I believe you should permute the dimensions to be [batch_size, 6, 6, 256] before doing the view.

See for example the original implementation of the authors:

https://github.com/Sarasra/models/blob/984fbc754943c849c55a57923f4223099a1ff88c/research/capsules/models/capsule_model.py#L68

@manuelsh Yes, you are totally right. Thanks.

What are your results if you do that? Our experience so far seems that with the correct view the results are actually worse. (!)

Btw, we are using cosine annealing as learning rate decay and works better than the exponential one.