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

Improper loop of b_IJ #7

Closed 13331151 closed 6 years ago

13331151 commented 6 years ago

Hi, Thanks for your great job. I found that the b_IJ is update with the order of J in your code. In CapsConv

            for j in range(self.num_outputs):
                with tf.variable_scope('caps_' + str(j)):
                    caps_j, b_IJ = capsule(input, b_IJ, j)
                    capsules.append(caps_j)

In capsule c_IJ = tf.nn.softmax(b_IJ, dim=2)

In your case, b_I(J+1) is not independent with b_IJ, which means the sequence matter the routing process. But in my opinion, all b_IJ should be update in parallel. Thanks for your reply in advance!

naturomics commented 6 years ago

Fixed by rewriting the whole routing algorithm in a matrix way