naturomics / CapsNet-Tensorflow

A Tensorflow implementation of CapsNet(Capsules Net) in paper Dynamic Routing Between Capsules
Apache License 2.0
3.8k stars 1.17k forks source link

Is your squashing input dimensions correct? #16

Closed isaacgerg closed 6 years ago

isaacgerg commented 6 years ago

If squashing is done per capsule, then whey is the input dimensions to it 32, 1152, 8, 1, where 32 is the batch size? Shouldn't it be 32, 668, 32, 1?

naturomics commented 6 years ago

Are you talking about this line of code?

32 is the batch size due to my GPU doesn't allow a bigger one(128 in paper). I don't know why you think it is [668, 32, 1] in the last three dims; as 1152 represents the number of capsule in the primaryCaps layer, and 8 for the length of vector s_j / v_j, where v_j is the vector output of capsule j of primaryCaps layer. In Eq. 1, || s_j || do a square norm for each v_j, where j ranges from 0 to 1152. Now, I would like to think this s_j as a vector with shape 8x1, then square_norm(s_j) = ? I think that's pretty clear.

Feel free to correct me if you believe I am wrong.

isaacgerg commented 6 years ago

Yes.

I was under the impression that there were 32 capsules in the network, not 1152. Is this not true?

naturomics commented 6 years ago

@isaacgerg Although there are not 1152 independent capsules, due to the 6x6 grid capsules share their weights, but you should count each [8,1] vector as the output of one capsule, so we have 6x6x32=1152