Desire100 / Capsule-Network-and-CNN-Keras-Implementation-on-MNIST-Dataset

This repo contains the steps of how to build Capsule network and Convolutional Neural Network for MNIST dataset
3 stars 2 forks source link

TensorFlow 2 #1

Open keeshanam opened 4 years ago

keeshanam commented 4 years ago

Hi,

Trying to run on TF 2 and get following:

19 # routing algorithm with updating coupling coefficient c, using scalar product b/w input capsule and output capsule
     20         for i in range(3-1):
---> 21             c = tf.nn.softmax(b, dim=1)
     22             s = K.batch_dot(c, inputs, [2, 2])
     23             v = squash(s)

TypeError: softmax_v2() got an unexpected keyword argument 'dim'

As per TF docs dim: Deprecated alias for axis

By changing dim to axis get following eror:

Can not do batch_dot on inputs with shapes (None, 10, 10, 1152, 16) and (None, 10, 1152, 1152, 16) with axes=[2, 3]. x.shape[2] != y.shape[3] (10 != 1152)

Regards,

Aidan

Desire100 commented 4 years ago

Hello Aidan

check out these two links https://github.com/XifengGuo/CapsNet-Keras/issues/94

https://www.kaggle.com/kmader/capsulenet-on-mnist

data-hound commented 4 years ago

@keeshanam

Check this issue https://github.com/XifengGuo/CapsNet-Keras/issues/104 There is a change in the behaviour of batch_dot going forward from Keras2.2.5