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

Inconsistency with the Paper #30

Closed maorbernstein closed 6 years ago

maorbernstein commented 6 years ago

I noticed when reading your code that you have left an inconsistency between your code and the original paper by Hinton. When you run the decoder, the input is the masked only correct capsule. This does not follow what Hinton did in the paper, because they mask the remaining capsules to 0, and pass all of the capsules to the next layer. This way positionally, the decoder can decide what it is trying to construct. The specific error is in this line self.masked_v = tf.matmul(tf.squeeze(self.caps2), tf.reshape(self.Y, (-1, 10, 1)), transpose_a=True). Therefore the first layer of the decoder should take an input of size 160, not 16.

naturomics commented 6 years ago

@maorbernstein Wow, you found it! I've been wondering why the testing accuracy is not as good as the paper. I got 99.58%, but paper 99.75%. Maybe it's caused by this problem. I'll try it out, thank you every much!