CapsNet-Pytorch icon indicating copy to clipboard operation
CapsNet-Pytorch copied to clipboard

Construction of PrimaryCaps

Open manuelsh opened this issue 7 years ago • 3 comments

I believe this line:

https://github.com/XifengGuo/CapsNet-Pytorch/blob/8a5a3572d91eb9479425168d3d565eb02e78be46/capsulelayers.py#L104

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.

manuelsh avatar Feb 18 '18 10:02 manuelsh

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 avatar Mar 05 '18 14:03 manuelsh

@manuelsh Yes, you are totally right. Thanks.

XifengGuo avatar Mar 06 '18 07:03 XifengGuo

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.

manuelsh avatar Mar 06 '18 10:03 manuelsh