You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, @XifengGuo greetings. I was using your capsnet implementation for a multi-label classification where model output 3 in number for each label target. However, I've faced the following error.
Each three output has a different number of classes. For example, the labels are A, B, and C. Label A has 168 different class, whereas B has 11 and C has 7. A basic set-up has given below:
def CapsNet:
............... more code ......................
# Layer 3: Capsule layer. Routing algorithm works here.
digitcaps_0 = CapsuleLayer(num_capsule=168,
dim_capsule=16,
routings=routings,
name='digitcaps_0')(primarycaps)
digitcaps_1 = CapsuleLayer(num_capsule=11,
dim_capsule=16,
routings=routings,
name='digitcaps_1')(primarycaps)
digitcaps_2 = CapsuleLayer(num_capsule=7,
dim_capsule=16,
routings=routings,
name='digitcaps_2')(primarycaps)
# Layer 4
out_caps_0 = Length(name='out_caps_gra')(digitcaps_0)
out_caps_1 = Length(name='out_caps_vow')(digitcaps_1)
out_caps_2 = Length(name='out_caps_cons')(digitcaps_2)
# Models for training
train_model = models.Model(inputs=[x], outputs=[out_caps_0,
out_caps_1,
out_caps_2])
return train_model
# build the model
model = CapsNet(input_shape=[64, 64, 1], routings=3)
And it threw the following error. The logs
ValueError Traceback (most recent call last)
<ipython-input-23-9f7ff279bacc> in <module>
1 import tensorflow as tf
2
----> 3 model = CapsNet(input_shape=[64, 64, 1], routings=3)
<ipython-input-22-1735b9121899> in CapsNet(input_shape, routings)
109 dim_capsule=16,
110 routings=routings,
--> 111 name='digitcaps_gra')(primarycaps)
112
113 digitcaps_vow = CapsuleLayer(num_capsule=11,
c:\users\devlix\.conda\envs\tflite\lib\site-packages\keras\engine\base_layer.py in __call__(self, inputs, **kwargs)
487 # Actually call the layer,
488 # collecting output(s), mask(s), and shape(s).
--> 489 output = self.call(inputs, **kwargs)
490 output_mask = self.compute_mask(inputs, previous_mask)
491
<ipython-input-10-d94539d78fd5> in call(self, inputs, training)
154 # then matmal: [dim_capsule] x [input_num_capsule, dim_capsule]^T -> [input_num_capsule].
155 # b.shape=[batch_size, num_capsule, input_num_capsule]
--> 156 b += K.batch_dot(outputs, inputs_hat, [2, 3])
157 # End: Routing algorithm -----------------------------------------------------------------------#
158
c:\users\devlix\.conda\envs\tflite\lib\site-packages\keras\backend\tensorflow_backend.py in batch_dot(x, y, axes)
1497 str(x_shape) + ' and ' + str(y_shape) +
1498 ' with axes=' + str(axes) + '. x.shape[%d] != '
-> 1499 'y.shape[%d] (%d != %d).' % (axes[0], axes[1], d1, d2))
1500
1501 # backup ndims. Need them later.
ValueError: Can not do batch_dot on inputs with shapes (None, 168, 168, 18432, 16) and (None, 168, None, 18432, 16) with axes=[2, 3]. x.shape[2] != y.shape[3] (168 != 18432).
Any catch? TIA.
The text was updated successfully, but these errors were encountered:
Hello, @XifengGuo greetings. I was using your
capsnet
implementation for a multi-label classification where model output 3 in number for each label target. However, I've faced the following error.Each three output has a different number of classes. For example, the labels are A, B, and C. Label A has 168 different class, whereas B has 11 and C has 7. A basic set-up has given below:
And it threw the following error. The logs
Any catch? TIA.
The text was updated successfully, but these errors were encountered: